Skip to content
Snippets Groups Projects
Commit 453a412e authored by marihachi's avatar marihachi
Browse files

update test

parent 97a362cf
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ import assert from 'assert';
import { parse, parsePlain } from '../built/index';
import { createNode } from '../built/util';
import {
TEXT, CENTER, FN, UNI_EMOJI, MENTION, CUSTOM_EMOJI, HASHTAG, N_URL
TEXT, CENTER, FN, UNI_EMOJI, MENTION, CUSTOM_EMOJI, HASHTAG, N_URL, BOLD, SMALL, ITALIC, STRIKE
} from './node';
describe('text', () => {
......@@ -12,6 +12,184 @@ describe('text', () => {
assert.deepStrictEqual(parse(input), output);
});
});
describe('fn', () => {
it('basic', () => {
const input = '[tada abc]';
const output = [
FN('tada', { }, [
TEXT('abc')
])
];
assert.deepStrictEqual(parse(input), output);
});
});
describe('big', () => {
it('basic', () => {
const input = '***abc***';
const output = [
FN('tada', { }, [
TEXT('abc')
])
];
assert.deepStrictEqual(parse(input), output);
});
it('内容にはインライン構文を利用できる', () => {
const input = '***123**abc**123***';
const output = [
FN('tada', { }, [
TEXT('123'),
BOLD([
TEXT('abc')
]),
TEXT('123')
])
];
assert.deepStrictEqual(parse(input), output);
});
it('内容は改行できる', () => {
const input = '***123\n**abc**\n123***';
const output = [
FN('tada', { }, [
TEXT('123\n'),
BOLD([
TEXT('abc')
]),
TEXT('\n123')
])
];
assert.deepStrictEqual(parse(input), output);
});
});
describe('bold', () => {
it('basic', () => {
const input = '**abc**';
const output = [
BOLD([
TEXT('abc')
])
];
assert.deepStrictEqual(parse(input), output);
});
it('内容にはインライン構文を利用できる', () => {
const input = '**123~~abc~~123**';
const output = [
BOLD([
TEXT('123'),
STRIKE([
TEXT('abc')
]),
TEXT('123')
])
];
assert.deepStrictEqual(parse(input), output);
});
it('内容は改行できる', () => {
const input = '**123\n~~abc~~\n123**';
const output = [
BOLD([
TEXT('123\n'),
STRIKE([
TEXT('abc')
]),
TEXT('\n123')
])
];
assert.deepStrictEqual(parse(input), output);
});
});
describe('small', () => {
it('basic', () => {
const input = '<small>abc</small>';
const output = [
SMALL([
TEXT('abc')
])
];
assert.deepStrictEqual(parse(input), output);
});
it('内容にはインライン構文を利用できる', () => {
const input = '<small>abc**123**abc</small>';
const output = [
SMALL([
TEXT('abc'),
BOLD([
TEXT('123')
]),
TEXT('abc')
])
];
assert.deepStrictEqual(parse(input), output);
});
it('内容は改行できる', () => {
const input = '<small>abc\n**123**\nabc</small>';
const output = [
SMALL([
TEXT('abc\n'),
BOLD([
TEXT('123')
]),
TEXT('\nabc')
])
];
assert.deepStrictEqual(parse(input), output);
});
});
describe('italic 1', () => {
it('basic', () => {
const input = '<i>abc</i>';
const output = [
ITALIC([
TEXT('abc')
])
];
assert.deepStrictEqual(parse(input), output);
});
it('内容にはインライン構文を利用できる', () => {
const input = '<i>abc**123**abc</i>';
const output = [
ITALIC([
TEXT('abc'),
BOLD([
TEXT('123')
]),
TEXT('abc')
])
];
assert.deepStrictEqual(parse(input), output);
});
it('内容は改行できる', () => {
const input = '<i>abc\n**123**\nabc</i>';
const output = [
ITALIC([
TEXT('abc\n'),
BOLD([
TEXT('123')
]),
TEXT('\nabc')
])
];
assert.deepStrictEqual(parse(input), output);
});
});
describe('italic 2', () => {
it('basic', () => {
const input = '*abc*';
const output = [
ITALIC([
TEXT('abc')
])
];
assert.deepStrictEqual(parse(input), output);
});
});
describe('custom emoji', () => {
it('basic', () => {
const input = ':abc:';
......
import { MfmCenter, MfmEmoji, MfmFn, MfmHashtag, MfmInline, MfmMention, MfmText, MfmUrl } from '../built';
import {
MfmBold, MfmCenter, MfmCodeBlock, MfmEmoji, MfmFn, MfmHashtag, MfmInline,
MfmInlineCode, MfmItalic, MfmLink, MfmMathBlock, MfmMathInline, MfmMention,
MfmNode, MfmQuote, MfmSearch, MfmSmall, MfmStrike, MfmText, MfmUrl
} from '../built';
export const TEXT = (value: string): MfmText => { return { type:'text', props: { text: value }, children: [] }; };
export const CUSTOM_EMOJI = (name: string): MfmEmoji => { return { type:'emoji', props: { name: name }, children: [] }; };
export const UNI_EMOJI = (value: string): MfmEmoji => { return { type:'emoji', props: { emoji: value }, children: [] }; };
export const QUOTE = (children: MfmNode[]): MfmQuote => { return { type:'quote', props: { }, children }; };
export const SEARCH = (q: string, content: string): MfmSearch => { return { type:'search', props: { q, content }, children: [] }; };
export const CODE_BLOCK = (code: string, lang: string | null): MfmCodeBlock => { return { type:'blockCode', props: { code, lang }, children: [] }; };
export const MATH_BLOCK = (formula: string): MfmMathBlock => { return { type:'mathBlock', props: { formula }, children: [] }; };
export const CENTER = (children: MfmInline[]): MfmCenter => { return { type:'center', props: { }, children }; };
export const BOLD = (children: MfmInline[]): MfmBold => { return { type:'bold', props: { }, children }; };
export const SMALL = (children: MfmInline[]): MfmSmall => { return { type:'small', props: { }, children }; };
export const ITALIC = (children: MfmInline[]): MfmItalic => { return { type:'italic', props: { }, children }; };
export const STRIKE = (children: MfmInline[]): MfmStrike => { return { type:'strike', props: { }, children }; };
export const INLINE_CODE = (code: string): MfmInlineCode => { return { type:'inlineCode', props: { code }, children: [] }; };
export const MATH_INLINE = (formula: string): MfmMathInline => { return { type:'mathInline', props: { formula }, children: [] }; };
export const MENTION = (username: string, host: string | null, acct: string): MfmMention => { return { type:'mention', props: { username, host, acct }, children: [] }; };
export const HASHTAG = (value: string): MfmHashtag => { return { type:'hashtag', props: { hashtag: value }, children: [] }; };
export const N_URL = (value: string): MfmUrl => { return { type:'url', props: { url: value }, children: [] }; };
export const CENTER = (children: MfmInline[]): MfmCenter => { return { type:'center', props: { }, children }; };
export const LINK = (silent: boolean, url: string, children: MfmInline[]): MfmLink => { return { type:'link', props: { silent, url }, children }; };
export const CUSTOM_EMOJI = (name: string): MfmEmoji => { return { type:'emoji', props: { name: name }, children: [] }; };
export const FN = (name: string, args: MfmFn['props']['args'], children: MfmFn['children']): MfmFn => { return { type:'fn', props: { name, args }, children }; };
export const MENTION = (username: string, host: string | null, acct: string): MfmMention => { return { type:'mention', props: { username, host, acct }, children: [] }; };
export const UNI_EMOJI = (value: string): MfmEmoji => { return { type:'emoji', props: { emoji: value }, children: [] }; };
export const TEXT = (value: string): MfmText => { return { type:'text', props: { text: value }, children: [] }; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment