From ae92c2a9d0f022d39afd6b0b0155971cbf0669a8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 4 Feb 2023 09:30:39 +0900 Subject: [PATCH] chore: use test instead of it --- test-d/index.ts | 2 +- test/api.ts | 64 +++++----- test/parser.ts | 310 ++++++++++++++++++++++++------------------------ 3 files changed, 188 insertions(+), 188 deletions(-) diff --git a/test-d/index.ts b/test-d/index.ts index 160a025..388aca3 100644 --- a/test-d/index.ts +++ b/test-d/index.ts @@ -7,7 +7,7 @@ import { expectType } from 'tsd'; import { NodeType, MfmUrl } from '../src'; describe('#NodeType', () => { - it('returns node that has sprcified type', () => { + test('returns node that has sprcified type', () => { const x = null as unknown as NodeType<'url'>; expectType(x); }); diff --git a/test/api.ts b/test/api.ts index 1c7d20f..25b29e2 100644 --- a/test/api.ts +++ b/test/api.ts @@ -6,7 +6,7 @@ import { describe('API', () => { describe('toString', () => { - it('basic', () => { + test('basic', () => { const input = `before
@@ -20,12 +20,12 @@ after`; assert.strictEqual(mfm.toString(mfm.parse(input)), input); }); - it('single node', () => { + test('single node', () => { const input = '$[tada Hello]'; assert.strictEqual(mfm.toString(mfm.parse(input)[0]), '$[tada Hello]'); }); - it('quote', () => { + test('quote', () => { const input = ` > abc > @@ -36,128 +36,128 @@ after`; }); - it('search', () => { + test('search', () => { const input = 'MFM 書き方 123 Search'; assert.strictEqual(mfm.toString(mfm.parse(input)), input); }); - it('block code', () => { + test('block code', () => { const input = '```\nabc\n```'; assert.strictEqual(mfm.toString(mfm.parse(input)), input); }); - it('math block', () => { + test('math block', () => { const input = '\\[\ny = 2x + 1\n\\]'; assert.strictEqual(mfm.toString(mfm.parse(input)), input); }); - it('center', () => { + test('center', () => { const input = '
\nabc\n
'; assert.strictEqual(mfm.toString(mfm.parse(input)), input); }); - // it('center (single line)', () => { + // test('center (single line)', () => { // const input = '
abc
'; // assert.strictEqual(mfm.toString(mfm.parse(input)), input); // }); - it('emoji code', () => { + test('emoji code', () => { const input = ':abc:'; assert.strictEqual(mfm.toString(mfm.parse(input)), input); }); - it('unicode emoji', () => { + test('unicode emoji', () => { const input = '今起きた😇'; assert.strictEqual(mfm.toString(mfm.parse(input)), input); }); - it('big', () => { + test('big', () => { const input = '***abc***'; const output = '$[tada abc]'; assert.strictEqual(mfm.toString(mfm.parse(input)), output); }); - it('bold', () => { + test('bold', () => { const input = '**abc**'; assert.strictEqual(mfm.toString(mfm.parse(input)), input); }); - // it('bold tag', () => { + // test('bold tag', () => { // const input = 'abc'; // assert.strictEqual(mfm.toString(mfm.parse(input)), input); // }); - it('small', () => { + test('small', () => { const input = 'abc'; assert.strictEqual(mfm.toString(mfm.parse(input)), input); }); - // it('italic', () => { + // test('italic', () => { // const input = '*abc*'; // assert.strictEqual(mfm.toString(mfm.parse(input)), input); // }); - it('italic tag', () => { + test('italic tag', () => { const input = 'abc'; assert.strictEqual(mfm.toString(mfm.parse(input)), input); }); - it('strike', () => { + test('strike', () => { const input = '~~foo~~'; assert.strictEqual(mfm.toString(mfm.parse(input)), input); }); - // it('strike tag', () => { + // test('strike tag', () => { // const input = 'foo'; // assert.strictEqual(mfm.toString(mfm.parse(input)), input); // }); - it('inline code', () => { + test('inline code', () => { const input = 'AiScript: `#abc = 2`'; assert.strictEqual(mfm.toString(mfm.parse(input)), 'AiScript: `#abc = 2`'); }); - it('math inline', () => { + test('math inline', () => { const input = '\\(y = 2x + 3\\)'; assert.strictEqual(mfm.toString(mfm.parse(input)), '\\(y = 2x + 3\\)'); }); - it('hashtag', () => { + test('hashtag', () => { const input = 'a #misskey b'; assert.strictEqual(mfm.toString(mfm.parse(input)), 'a #misskey b'); }); - it('link', () => { + test('link', () => { const input = '[Ai](https://github.com/syuilo/ai)'; assert.strictEqual(mfm.toString(mfm.parse(input)), '[Ai](https://github.com/syuilo/ai)'); }); - it('silent link', () => { + test('silent link', () => { const input = '?[Ai](https://github.com/syuilo/ai)'; assert.strictEqual(mfm.toString(mfm.parse(input)), '?[Ai](https://github.com/syuilo/ai)'); }); - it('fn', () => { + test('fn', () => { const input = '$[tada Hello]'; assert.strictEqual(mfm.toString(mfm.parse(input)), '$[tada Hello]'); }); - it('fn with arguments', () => { + test('fn with arguments', () => { const input = '$[spin.speed=1s,alternate Hello]'; assert.strictEqual(mfm.toString(mfm.parse(input)), '$[spin.speed=1s,alternate Hello]'); }); - it('plain', () => { + test('plain', () => { const input = 'a\n\nHello\nworld\n\nb'; assert.strictEqual(mfm.toString(mfm.parse(input)), 'a\n\nHello\nworld\n\nb'); }); - it('1 line plain', () => { + test('1 line plain', () => { const input = 'a\nHello\nb'; assert.strictEqual(mfm.toString(mfm.parse(input)), 'a\n\nHello\n\nb'); }); - it('preserve url brackets', () => { + test('preserve url brackets', () => { const input1 = 'https://github.com/syuilo/ai'; assert.strictEqual(mfm.toString(mfm.parse(input1)), input1); @@ -167,7 +167,7 @@ after`; }); describe('inspect', () => { - it('replace text', () => { + test('replace text', () => { const input = 'good morning $[tada everynyan!]'; const result = mfm.parse(input); mfm.inspect(result, node => { @@ -178,7 +178,7 @@ after`; assert.strictEqual(mfm.toString(result), 'hello $[tada everynyan!]'); }); - it('replace text (one item)', () => { + test('replace text (one item)', () => { const input = 'good morning $[tada everyone!]'; const result = mfm.parse(input); mfm.inspect(result[1], node => { @@ -191,7 +191,7 @@ after`; }); describe('extract', () => { - it('basic', () => { + test('basic', () => { const nodes = mfm.parse('@hoge @piyo @bebeyo'); const expect = [ MENTION('hoge', null, '@hoge'), @@ -201,7 +201,7 @@ after`; assert.deepStrictEqual(mfm.extract(nodes, node => node.type == 'mention'), expect); }); - it('nested', () => { + test('nested', () => { const nodes = mfm.parse('abc:hoge:$[tada 123 @hoge :foo:]:piyo:'); const expect = [ EMOJI_CODE('hoge'), diff --git a/test/parser.ts b/test/parser.ts index 80e364d..50ae700 100644 --- a/test/parser.ts +++ b/test/parser.ts @@ -6,19 +6,19 @@ import { describe('SimpleParser', () => { describe('text', () => { - it('basic', () => { + test('basic', () => { const input = 'abc'; const output = [TEXT('abc')]; assert.deepStrictEqual(mfm.parseSimple(input), output); }); - it('ignore hashtag', () => { + test('ignore hashtag', () => { const input = 'abc#abc'; const output = [TEXT('abc#abc')]; assert.deepStrictEqual(mfm.parseSimple(input), output); }); - it('keycap number sign', () => { + test('keycap number sign', () => { const input = 'abc#️⃣abc'; const output = [TEXT('abc'), UNI_EMOJI('#️⃣'), TEXT('abc')]; assert.deepStrictEqual(mfm.parseSimple(input), output); @@ -26,32 +26,32 @@ describe('SimpleParser', () => { }); describe('emoji', () => { - it('basic', () => { + test('basic', () => { const input = ':foo:'; const output = [EMOJI_CODE('foo')]; assert.deepStrictEqual(mfm.parseSimple(input), output); }); - it('between texts', () => { + test('between texts', () => { const input = 'foo:bar:baz'; const output = [TEXT('foo:bar:baz')]; assert.deepStrictEqual(mfm.parseSimple(input), output); }); - it('between texts 2', () => { + test('between texts 2', () => { const input = '12:34:56'; const output = [TEXT('12:34:56')]; assert.deepStrictEqual(mfm.parseSimple(input), output); }); - it('between texts 3', () => { + test('between texts 3', () => { const input = 'あ:bar:い'; const output = [TEXT('あ'), EMOJI_CODE('bar'), TEXT('い')]; assert.deepStrictEqual(mfm.parseSimple(input), output); }); }); - it('disallow other syntaxes', () => { + test('disallow other syntaxes', () => { const input = 'foo **bar** baz'; const output = [TEXT('foo **bar** baz')]; assert.deepStrictEqual(mfm.parseSimple(input), output); @@ -60,7 +60,7 @@ describe('SimpleParser', () => { describe('FullParser', () => { describe('text', () => { - it('普通のテキストを入力すると1つのテキストノードが返される', () => { + test('普通のテキストを入力すると1つのテキストノードが返される', () => { const input = 'abc'; const output = [TEXT('abc')]; assert.deepStrictEqual(mfm.parse(input), output); @@ -68,7 +68,7 @@ describe('FullParser', () => { }); describe('quote', () => { - it('1行の引用ブロックを使用できる', () => { + test('1行の引用ブロックを使用できる', () => { const input = '> abc'; const output = [ QUOTE([ @@ -77,7 +77,7 @@ describe('FullParser', () => { ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('複数行の引用ブロックを使用できる', () => { + test('複数行の引用ブロックを使用できる', () => { const input = ` > abc > 123 @@ -89,7 +89,7 @@ describe('FullParser', () => { ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('引用ブロックはブロックをネストできる', () => { + test('引用ブロックはブロックをネストできる', () => { const input = ` >
> a @@ -104,7 +104,7 @@ describe('FullParser', () => { ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('引用ブロックはインライン構文を含んだブロックをネストできる', () => { + test('引用ブロックはインライン構文を含んだブロックをネストできる', () => { const input = ` >
> I'm @ai, An bot of misskey! @@ -121,7 +121,7 @@ describe('FullParser', () => { ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('複数行の引用ブロックでは空行を含めることができる', () => { + test('複数行の引用ブロックでは空行を含めることができる', () => { const input = ` > abc > @@ -134,14 +134,14 @@ describe('FullParser', () => { ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('1行の引用ブロックを空行にはできない', () => { + test('1行の引用ブロックを空行にはできない', () => { const input = '> '; const output = [ TEXT('> ') ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('引用ブロックの後ろの空行は無視される', () => { + test('引用ブロックの後ろの空行は無視される', () => { const input = ` > foo > bar @@ -155,7 +155,7 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('2つの引用行の間に空行がある場合は2つの引用ブロックが生成される', () => { + test('2つの引用行の間に空行がある場合は2つの引用ブロックが生成される', () => { const input = ` > foo @@ -177,42 +177,42 @@ hoge`; describe('search', () => { describe('検索構文を使用できる', () => { - it('Search', () => { + test('Search', () => { const input = 'MFM 書き方 123 Search'; const output = [ SEARCH('MFM 書き方 123', input) ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('[Search]', () => { + test('[Search]', () => { const input = 'MFM 書き方 123 [Search]'; const output = [ SEARCH('MFM 書き方 123', input) ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('search', () => { + test('search', () => { const input = 'MFM 書き方 123 search'; const output = [ SEARCH('MFM 書き方 123', input) ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('[search]', () => { + test('[search]', () => { const input = 'MFM 書き方 123 [search]'; const output = [ SEARCH('MFM 書き方 123', input) ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('検索', () => { + test('検索', () => { const input = 'MFM 書き方 123 検索'; const output = [ SEARCH('MFM 書き方 123', input) ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('[検索]', () => { + test('[検索]', () => { const input = 'MFM 書き方 123 [検索]'; const output = [ SEARCH('MFM 書き方 123', input) @@ -220,7 +220,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); }); - it('ブロックの前後にあるテキストが正しく解釈される', () => { + test('ブロックの前後にあるテキストが正しく解釈される', () => { const input = 'abc\nhoge piyo bebeyo 検索\n123'; const output = [ TEXT('abc'), @@ -232,25 +232,25 @@ hoge`; }); describe('code block', () => { - it('コードブロックを使用できる', () => { + test('コードブロックを使用できる', () => { const input = '```\nabc\n```'; const output = [CODE_BLOCK('abc', null)]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('コードブロックには複数行のコードを入力できる', () => { + test('コードブロックには複数行のコードを入力できる', () => { const input = '```\na\nb\nc\n```'; const output = [CODE_BLOCK('a\nb\nc', null)]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('コードブロックは言語を指定できる', () => { + test('コードブロックは言語を指定できる', () => { const input = '```js\nconst a = 1;\n```'; const output = [CODE_BLOCK('const a = 1;', 'js')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ブロックの前後にあるテキストが正しく解釈される', () => { + test('ブロックの前後にあるテキストが正しく解釈される', () => { const input = 'abc\n```\nconst abc = 1;\n```\n123'; const output = [ TEXT('abc'), @@ -260,13 +260,13 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore internal marker', () => { + test('ignore internal marker', () => { const input = '```\naaa```bbb\n```'; const output = [CODE_BLOCK('aaa```bbb', null)]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('trim after line break', () => { + test('trim after line break', () => { const input = '```\nfoo\n```\nbar'; const output = [ CODE_BLOCK('foo', null), @@ -277,14 +277,14 @@ hoge`; }); describe('mathBlock', () => { - it('1行の数式ブロックを使用できる', () => { + test('1行の数式ブロックを使用できる', () => { const input = '\\[math1\\]'; const output = [ MATH_BLOCK('math1') ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ブロックの前後にあるテキストが正しく解釈される', () => { + test('ブロックの前後にあるテキストが正しく解釈される', () => { const input = 'abc\n\\[math1\\]\n123'; const output = [ TEXT('abc'), @@ -293,14 +293,14 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('行末以外に閉じタグがある場合はマッチしない', () => { + test('行末以外に閉じタグがある場合はマッチしない', () => { const input = '\\[aaa\\]after'; const output = [ TEXT('\\[aaa\\]after') ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('行頭以外に開始タグがある場合はマッチしない', () => { + test('行頭以外に開始タグがある場合はマッチしない', () => { const input = 'before\\[aaa\\]'; const output = [ TEXT('before\\[aaa\\]') @@ -310,7 +310,7 @@ hoge`; }); describe('center', () => { - it('single text', () => { + test('single text', () => { const input = '
abc
'; const output = [ CENTER([ @@ -319,7 +319,7 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('multiple text', () => { + test('multiple text', () => { const input = 'before\n
\nabc\n123\n\npiyo\n
\nafter'; const output = [ TEXT('before'), @@ -333,7 +333,7 @@ hoge`; }); describe('emoji code', () => { - it('basic', () => { + test('basic', () => { const input = ':abc:'; const output = [EMOJI_CODE('abc')]; assert.deepStrictEqual(mfm.parse(input), output); @@ -341,13 +341,13 @@ hoge`; }); describe('unicode emoji', () => { - it('basic', () => { + test('basic', () => { const input = '今起きた😇'; const output = [TEXT('今起きた'), UNI_EMOJI('😇')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('keycap number sign', () => { + test('keycap number sign', () => { const input = 'abc#️⃣123'; const output = [TEXT('abc'), UNI_EMOJI('#️⃣'), TEXT('123')]; assert.deepStrictEqual(mfm.parse(input), output); @@ -355,7 +355,7 @@ hoge`; }); describe('big', () => { - it('basic', () => { + test('basic', () => { const input = '***abc***'; const output = [ FN('tada', { }, [ @@ -364,7 +364,7 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('内容にはインライン構文を利用できる', () => { + test('内容にはインライン構文を利用できる', () => { const input = '***123**abc**123***'; const output = [ FN('tada', { }, [ @@ -377,7 +377,7 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('内容は改行できる', () => { + test('内容は改行できる', () => { const input = '***123\n**abc**\n123***'; const output = [ FN('tada', { }, [ @@ -393,7 +393,7 @@ hoge`; }); describe('bold tag', () => { - it('basic', () => { + test('basic', () => { const input = 'abc'; const output = [ BOLD([ @@ -402,7 +402,7 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('inline syntax allowed inside', () => { + test('inline syntax allowed inside', () => { const input = '123~~abc~~123'; const output = [ BOLD([ @@ -415,7 +415,7 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('line breaks', () => { + test('line breaks', () => { const input = '123\n~~abc~~\n123'; const output = [ BOLD([ @@ -431,7 +431,7 @@ hoge`; }); describe('bold', () => { - it('basic', () => { + test('basic', () => { const input = '**abc**'; const output = [ BOLD([ @@ -440,7 +440,7 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('内容にはインライン構文を利用できる', () => { + test('内容にはインライン構文を利用できる', () => { const input = '**123~~abc~~123**'; const output = [ BOLD([ @@ -453,7 +453,7 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('内容は改行できる', () => { + test('内容は改行できる', () => { const input = '**123\n~~abc~~\n123**'; const output = [ BOLD([ @@ -469,7 +469,7 @@ hoge`; }); describe('small', () => { - it('basic', () => { + test('basic', () => { const input = 'abc'; const output = [ SMALL([ @@ -478,7 +478,7 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('内容にはインライン構文を利用できる', () => { + test('内容にはインライン構文を利用できる', () => { const input = 'abc**123**abc'; const output = [ SMALL([ @@ -491,7 +491,7 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('内容は改行できる', () => { + test('内容は改行できる', () => { const input = 'abc\n**123**\nabc'; const output = [ SMALL([ @@ -507,7 +507,7 @@ hoge`; }); describe('italic tag', () => { - it('basic', () => { + test('basic', () => { const input = 'abc'; const output = [ ITALIC([ @@ -516,7 +516,7 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('内容にはインライン構文を利用できる', () => { + test('内容にはインライン構文を利用できる', () => { const input = 'abc**123**abc'; const output = [ ITALIC([ @@ -529,7 +529,7 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('内容は改行できる', () => { + test('内容は改行できる', () => { const input = 'abc\n**123**\nabc'; const output = [ ITALIC([ @@ -545,7 +545,7 @@ hoge`; }); describe('italic alt 1', () => { - it('basic', () => { + test('basic', () => { const input = '*abc*'; const output = [ ITALIC([ @@ -555,7 +555,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('basic 2', () => { + test('basic 2', () => { const input = 'before *abc* after'; const output = [ TEXT('before '), @@ -567,7 +567,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore a italic syntax if the before char is neither a space nor an LF nor [^a-z0-9]i', () => { + test('ignore a italic syntax if the before char is neither a space nor an LF nor [^a-z0-9]i', () => { let input = 'before*abc*after'; let output: mfm.MfmNode[] = [TEXT('before*abc*after')]; assert.deepStrictEqual(mfm.parse(input), output); @@ -585,7 +585,7 @@ hoge`; }); describe('italic alt 2', () => { - it('basic', () => { + test('basic', () => { const input = '_abc_'; const output = [ ITALIC([ @@ -595,7 +595,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('basic 2', () => { + test('basic 2', () => { const input = 'before _abc_ after'; const output = [ TEXT('before '), @@ -607,7 +607,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore a italic syntax if the before char is neither a space nor an LF nor [^a-z0-9]i', () => { + test('ignore a italic syntax if the before char is neither a space nor an LF nor [^a-z0-9]i', () => { let input = 'before_abc_after'; let output: mfm.MfmNode[] = [TEXT('before_abc_after')]; assert.deepStrictEqual(mfm.parse(input), output); @@ -625,7 +625,7 @@ hoge`; }); describe('strike tag', () => { - it('basic', () => { + test('basic', () => { const input = 'foo'; const output = [STRIKE([ TEXT('foo') @@ -635,7 +635,7 @@ hoge`; }); describe('strike', () => { - it('basic', () => { + test('basic', () => { const input = '~~foo~~'; const output = [STRIKE([ TEXT('foo') @@ -645,19 +645,19 @@ hoge`; }); describe('inlineCode', () => { - it('basic', () => { + test('basic', () => { const input = '`var x = "Strawberry Pasta";`'; const output = [INLINE_CODE('var x = "Strawberry Pasta";')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('disallow line break', () => { + test('disallow line break', () => { const input = '`foo\nbar`'; const output = [TEXT('`foo\nbar`')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('disallow ´', () => { + test('disallow ´', () => { const input = '`foo´bar`'; const output = [TEXT('`foo´bar`')]; assert.deepStrictEqual(mfm.parse(input), output); @@ -665,7 +665,7 @@ hoge`; }); describe('mathInline', () => { - it('basic', () => { + test('basic', () => { const input = '\\(x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}\\)'; const output = [MATH_INLINE('x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}')]; assert.deepStrictEqual(mfm.parse(input), output); @@ -673,97 +673,97 @@ hoge`; }); describe('mention', () => { - it('basic', () => { + test('basic', () => { const input = '@abc'; const output = [MENTION('abc', null, '@abc')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('basic 2', () => { + test('basic 2', () => { const input = 'before @abc after'; const output = [TEXT('before '), MENTION('abc', null, '@abc'), TEXT(' after')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('basic remote', () => { + test('basic remote', () => { const input = '@abc@misskey.io'; const output = [MENTION('abc', 'misskey.io', '@abc@misskey.io')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('basic remote 2', () => { + test('basic remote 2', () => { const input = 'before @abc@misskey.io after'; const output = [TEXT('before '), MENTION('abc', 'misskey.io', '@abc@misskey.io'), TEXT(' after')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('basic remote 3', () => { + test('basic remote 3', () => { const input = 'before\n@abc@misskey.io\nafter'; const output = [TEXT('before\n'), MENTION('abc', 'misskey.io', '@abc@misskey.io'), TEXT('\nafter')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore format of mail address', () => { + test('ignore format of mail address', () => { const input = 'abc@example.com'; const output = [TEXT('abc@example.com')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('detect as a mention if the before char is [^a-z0-9]i', () => { + test('detect as a mention if the before char is [^a-z0-9]i', () => { const input = 'あいう@abc'; const output = [TEXT('あいう'), MENTION('abc', null, '@abc')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('invalid char only username', () => { + test('invalid char only username', () => { const input = '@-'; const output = [TEXT('@-')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('invalid char only hostname', () => { + test('invalid char only hostname', () => { const input = '@abc@.'; const output = [TEXT('@abc@.')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('allow "-" in username', () => { + test('allow "-" in username', () => { const input = '@abc-d'; const output = [MENTION('abc-d', null, '@abc-d')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('disallow "-" in head of username', () => { + test('disallow "-" in head of username', () => { const input = '@-abc'; const output = [TEXT('@-abc')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('disallow "-" in tail of username', () => { + test('disallow "-" in tail of username', () => { const input = '@abc-'; const output = [MENTION('abc', null, '@abc'), TEXT('-')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('disallow "." in head of hostname', () => { + test('disallow "." in head of hostname', () => { const input = '@abc@.aaa'; const output = [TEXT('@abc@.aaa')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('disallow "." in tail of hostname', () => { + test('disallow "." in tail of hostname', () => { const input = '@abc@aaa.'; const output = [MENTION('abc', 'aaa', '@abc@aaa'), TEXT('.')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('disallow "-" in head of hostname', () => { + test('disallow "-" in head of hostname', () => { const input = '@abc@-aaa'; const output = [TEXT('@abc@-aaa')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('disallow "-" in tail of hostname', () => { + test('disallow "-" in tail of hostname', () => { const input = '@abc@aaa-'; const output = [MENTION('abc', 'aaa', '@abc@aaa'), TEXT('-')]; assert.deepStrictEqual(mfm.parse(input), output); @@ -771,32 +771,32 @@ hoge`; }); describe('hashtag', () => { - it('basic', () => { + test('basic', () => { const input = '#abc'; const output = [HASHTAG('abc')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('basic 2', () => { + test('basic 2', () => { const input = 'before #abc after'; const output = [TEXT('before '), HASHTAG('abc'), TEXT(' after')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('with keycap number sign', () => { + test('with keycap number sign', () => { const input = '#️⃣abc123 #abc'; const output = [UNI_EMOJI('#️⃣'), TEXT('abc123 '), HASHTAG('abc')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('with keycap number sign 2', () => { + test('with keycap number sign 2', () => { const input = `abc #️⃣abc`; const output = [TEXT('abc\n'), UNI_EMOJI('#️⃣'), TEXT('abc')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore a hashtag if the before char is neither a space nor an LF nor [^a-z0-9]i', () => { + test('ignore a hashtag if the before char is neither a space nor an LF nor [^a-z0-9]i', () => { let input = 'abc#abc'; let output: mfm.MfmNode[] = [TEXT('abc#abc')]; assert.deepStrictEqual(mfm.parse(input), output); @@ -806,97 +806,97 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore comma and period', () => { + test('ignore comma and period', () => { const input = 'Foo #bar, baz #piyo.'; const output = [TEXT('Foo '), HASHTAG('bar'), TEXT(', baz '), HASHTAG('piyo'), TEXT('.')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore exclamation mark', () => { + test('ignore exclamation mark', () => { const input = '#Foo!'; const output = [HASHTAG('Foo'), TEXT('!')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore colon', () => { + test('ignore colon', () => { const input = '#Foo:'; const output = [HASHTAG('Foo'), TEXT(':')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore single quote', () => { + test('ignore single quote', () => { const input = '#Foo\''; const output = [HASHTAG('Foo'), TEXT('\'')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore double quote', () => { + test('ignore double quote', () => { const input = '#Foo"'; const output = [HASHTAG('Foo'), TEXT('"')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore square bracket', () => { + test('ignore square bracket', () => { const input = '#Foo]'; const output = [HASHTAG('Foo'), TEXT(']')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore slash', () => { + test('ignore slash', () => { const input = '#foo/bar'; const output = [HASHTAG('foo'), TEXT('/bar')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore angle bracket', () => { + test('ignore angle bracket', () => { const input = '#foo'; const output = [HASHTAG('foo'), TEXT('')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('allow including number', () => { + test('allow including number', () => { const input = '#foo123'; const output = [HASHTAG('foo123')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('with brackets "()"', () => { + test('with brackets "()"', () => { const input = '(#foo)'; const output = [TEXT('('), HASHTAG('foo'), TEXT(')')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('with brackets "「」"', () => { + test('with brackets "「」"', () => { const input = '「#foo」'; const output = [TEXT('「'), HASHTAG('foo'), TEXT('」')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('with mixed brackets', () => { + test('with mixed brackets', () => { const input = '「#foo(bar)」'; const output = [TEXT('「'), HASHTAG('foo(bar)'), TEXT('」')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('with brackets "()" (space before)', () => { + test('with brackets "()" (space before)', () => { const input = '(bar #foo)'; const output = [TEXT('(bar '), HASHTAG('foo'), TEXT(')')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('with brackets "「」" (space before)', () => { + test('with brackets "「」" (space before)', () => { const input = '「bar #foo」'; const output = [TEXT('「bar '), HASHTAG('foo'), TEXT('」')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('disallow number only', () => { + test('disallow number only', () => { const input = '#123'; const output = [TEXT('#123')]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('disallow number only (with brackets)', () => { + test('disallow number only (with brackets)', () => { const input = '(#123)'; const output = [TEXT('(#123)')]; assert.deepStrictEqual(mfm.parse(input), output); @@ -904,7 +904,7 @@ hoge`; }); describe('url', () => { - it('basic', () => { + test('basic', () => { const input = 'https://misskey.io/@ai'; const output = [ N_URL('https://misskey.io/@ai'), @@ -912,7 +912,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('with other texts', () => { + test('with other texts', () => { const input = 'official instance: https://misskey.io/@ai.'; const output = [ TEXT('official instance: '), @@ -922,7 +922,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore trailing period', () => { + test('ignore trailing period', () => { const input = 'https://misskey.io/@ai.'; const output = [ N_URL('https://misskey.io/@ai'), @@ -931,7 +931,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('disallow period only', () => { + test('disallow period only', () => { const input = 'https://.'; const output = [ TEXT('https://.') @@ -939,7 +939,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore trailing periods', () => { + test('ignore trailing periods', () => { const input = 'https://misskey.io/@ai...'; const output = [ N_URL('https://misskey.io/@ai'), @@ -948,7 +948,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('with comma', () => { + test('with comma', () => { const input = 'https://example.com/foo?bar=a,b'; const output = [ N_URL('https://example.com/foo?bar=a,b'), @@ -956,7 +956,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore trailing comma', () => { + test('ignore trailing comma', () => { const input = 'https://example.com/foo, bar'; const output = [ N_URL('https://example.com/foo'), @@ -965,7 +965,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('with brackets', () => { + test('with brackets', () => { const input = 'https://example.com/foo(bar)'; const output = [ N_URL('https://example.com/foo(bar)'), @@ -973,7 +973,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore parent brackets', () => { + test('ignore parent brackets', () => { const input = '(https://example.com/foo)'; const output = [ TEXT('('), @@ -983,7 +983,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore parent brackets (2)', () => { + test('ignore parent brackets (2)', () => { const input = '(foo https://example.com/foo)'; const output = [ TEXT('(foo '), @@ -993,7 +993,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore parent brackets with internal brackets', () => { + test('ignore parent brackets with internal brackets', () => { const input = '(https://example.com/foo(bar))'; const output = [ TEXT('('), @@ -1003,7 +1003,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore parent []', () => { + test('ignore parent []', () => { const input = 'foo [https://example.com/foo] bar'; const output = [ TEXT('foo ['), @@ -1013,7 +1013,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('ignore non-ascii characters contained url without angle brackets', () => { + test('ignore non-ascii characters contained url without angle brackets', () => { const input = 'https://大石泉すき.example.com'; const output = [ TEXT('https://大石泉すき.example.com'), @@ -1021,7 +1021,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('match non-ascii characters contained url with angle brackets', () => { + test('match non-ascii characters contained url with angle brackets', () => { const input = ''; const output = [ N_URL('https://大石泉すき.example.com', true), @@ -1029,7 +1029,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('prevent xss', () => { + test('prevent xss', () => { const input = 'javascript:foo'; const output = [ TEXT('javascript:foo') @@ -1039,7 +1039,7 @@ hoge`; }); describe('link', () => { - it('basic', () => { + test('basic', () => { const input = '[official instance](https://misskey.io/@ai).'; const output = [ LINK(false, 'https://misskey.io/@ai', [ @@ -1050,7 +1050,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('silent flag', () => { + test('silent flag', () => { const input = '?[official instance](https://misskey.io/@ai).'; const output = [ LINK(true, 'https://misskey.io/@ai', [ @@ -1061,7 +1061,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('with angle brackets url', () => { + test('with angle brackets url', () => { const input = '[official instance]().'; const output = [ LINK(false, 'https://misskey.io/@ai', [ @@ -1072,7 +1072,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('prevent xss', () => { + test('prevent xss', () => { const input = '[click here](javascript:foo)'; const output = [ TEXT('[click here](javascript:foo)') @@ -1081,7 +1081,7 @@ hoge`; }); describe('cannot nest a url in a link label', () => { - it('basic', () => { + test('basic', () => { const input = 'official instance: [https://misskey.io/@ai](https://misskey.io/@ai).'; const output = [ TEXT('official instance: '), @@ -1092,7 +1092,7 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('nested', () => { + test('nested', () => { const input = 'official instance: [https://misskey.io/@ai**https://misskey.io/@ai**](https://misskey.io/@ai).'; const output = [ TEXT('official instance: '), @@ -1109,7 +1109,7 @@ hoge`; }); describe('cannot nest a link in a link label', () => { - it('basic', () => { + test('basic', () => { const input = 'official instance: [[https://misskey.io/@ai](https://misskey.io/@ai)](https://misskey.io/@ai).'; const output = [ TEXT('official instance: '), @@ -1122,7 +1122,7 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('nested', () => { + test('nested', () => { const input = 'official instance: [**[https://misskey.io/@ai](https://misskey.io/@ai)**](https://misskey.io/@ai).'; const output = [ TEXT('official instance: '), @@ -1137,7 +1137,7 @@ hoge`; }); describe('cannot nest a mention in a link label', () => { - it('basic', () => { + test('basic', () => { const input = '[@example](https://example.com)'; const output = [ LINK(false, 'https://example.com', [ @@ -1146,7 +1146,7 @@ hoge`; ]; assert.deepStrictEqual(mfm.parse(input), output); }); - it('nested', () => { + test('nested', () => { const input = '[@example**@example**](https://example.com)'; const output = [ LINK(false, 'https://example.com', [ @@ -1160,7 +1160,7 @@ hoge`; }); }); - it('with brackets', () => { + test('with brackets', () => { const input = '[foo](https://example.com/foo(bar))'; const output = [ LINK(false, 'https://example.com/foo(bar)', [ @@ -1170,7 +1170,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('with parent brackets', () => { + test('with parent brackets', () => { const input = '([foo](https://example.com/foo(bar)))'; const output = [ TEXT('('), @@ -1182,7 +1182,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('with brackets before', () => { + test('with brackets before', () => { const input = '[test] foo [bar](https://example.com)'; const output = [ TEXT('[test] foo '), @@ -1195,7 +1195,7 @@ hoge`; }); describe('fn', () => { - it('basic', () => { + test('basic', () => { const input = '$[tada abc]'; const output = [ FN('tada', { }, [ @@ -1205,7 +1205,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('with a string argument', () => { + test('with a string argument', () => { const input = '$[spin.speed=1.1s a]'; const output = [ FN('spin', { speed: '1.1s' }, [ @@ -1215,7 +1215,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('with a string argument 2', () => { + test('with a string argument 2', () => { const input = '$[position.x=-3 a]'; const output = [ FN('position', { x: '-3' }, [ @@ -1225,7 +1225,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('invalid fn name', () => { + test('invalid fn name', () => { const input = '$[関数 text]'; const output = [ TEXT('$[関数 text]') @@ -1233,7 +1233,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('nest', () => { + test('nest', () => { const input = '$[spin.speed=1.1s $[shake a]]'; const output = [ FN('spin', { speed: '1.1s' }, [ @@ -1247,7 +1247,7 @@ hoge`; }); describe('plain', () => { - it('multiple line', () => { + test('multiple line', () => { const input = 'a\n\n**Hello**\nworld\n\nb'; const output = [ TEXT('a\n'), @@ -1257,7 +1257,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('single line', () => { + test('single line', () => { const input = 'a\n**Hello** world\nb'; const output = [ TEXT('a\n'), @@ -1270,7 +1270,7 @@ hoge`; describe('nesting limit', () => { describe('quote', () => { - it('basic', () => { + test('basic', () => { const input = '>>> abc'; const output = [ QUOTE([ @@ -1282,7 +1282,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input, { nestLimit: 2 }), output); }); - it('basic 2', () => { + test('basic 2', () => { const input = '>> **abc**'; const output = [ QUOTE([ @@ -1295,7 +1295,7 @@ hoge`; }); }); - it('big', () => { + test('big', () => { const input = '***abc***'; const output = [ BOLD([ @@ -1308,7 +1308,7 @@ hoge`; }); describe('bold', () => { - it('basic', () => { + test('basic', () => { const input = '**abc**'; const output = [ ITALIC([ @@ -1320,7 +1320,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input, { nestLimit: 2 }), output); }); - it('tag', () => { + test('tag', () => { const input = 'abc'; const output = [ ITALIC([ @@ -1333,7 +1333,7 @@ hoge`; }); }); - it('small', () => { + test('small', () => { const input = 'abc'; const output = [ ITALIC([ @@ -1345,7 +1345,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input, { nestLimit: 2 }), output); }); - it('italic', () => { + test('italic', () => { const input = 'abc'; const output = [ BOLD([ @@ -1358,7 +1358,7 @@ hoge`; }); describe('strike', () => { - it('basic', () => { + test('basic', () => { const input = '~~abc~~'; const output = [ BOLD([ @@ -1370,7 +1370,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input, { nestLimit: 2 }), output); }); - it('tag', () => { + test('tag', () => { const input = 'abc'; const output = [ BOLD([ @@ -1384,7 +1384,7 @@ hoge`; }); describe('hashtag', () => { - it('basic', () => { + test('basic', () => { let input, output; input = '#abc(xyz)'; output = [ @@ -1403,7 +1403,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input, { nestLimit: 2 }), output); }); - it('outside "()"', () => { + test('outside "()"', () => { const input = '(#abc)'; const output = [ TEXT('('), @@ -1413,7 +1413,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('outside "[]"', () => { + test('outside "[]"', () => { const input = '[#abc]'; const output = [ TEXT('['), @@ -1423,7 +1423,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('outside "「」"', () => { + test('outside "「」"', () => { const input = '「#abc」'; const output = [ TEXT('「'), @@ -1433,7 +1433,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input), output); }); - it('outside "()"', () => { + test('outside "()"', () => { const input = '(#abc)'; const output = [ TEXT('('), @@ -1444,7 +1444,7 @@ hoge`; }); }); - it('url', () => { + test('url', () => { let input, output; input = 'https://example.com/abc(xyz)'; output = [ @@ -1463,7 +1463,7 @@ hoge`; assert.deepStrictEqual(mfm.parse(input, { nestLimit: 2 }), output); }); - it('fn', () => { + test('fn', () => { const input = '$[a b]'; const output = [ BOLD([ @@ -1476,7 +1476,7 @@ hoge`; }); }); - it('composite', () => { + test('composite', () => { const input = `before