From 5ff959c790445ee202858eea93da8d1e7d864d74 Mon Sep 17 00:00:00 2001 From: marihachi <marihachi0620@gmail.com> Date: Thu, 15 Apr 2021 16:53:55 +0900 Subject: [PATCH] add test --- test/parser.ts | 52 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/test/parser.ts b/test/parser.ts index 1c70b24..6b564d5 100644 --- a/test/parser.ts +++ b/test/parser.ts @@ -366,7 +366,7 @@ describe('FullParser', () => { }); }); - describe('italic 1', () => { + describe('italic tag', () => { it('basic', () => { const input = '<i>abc</i>'; const output = [ @@ -404,7 +404,7 @@ describe('FullParser', () => { }); }); - describe('italic 2', () => { + describe('italic alt 1', () => { it('basic', () => { const input = '*abc*'; const output = [ @@ -414,6 +414,54 @@ describe('FullParser', () => { ]; assert.deepStrictEqual(mfm.parse(input), output); }); + + it('basic 2', () => { + const input = 'before *abc* after'; + const output = [ + TEXT('before '), + ITALIC([ + TEXT('abc') + ]), + TEXT(' after') + ]; + assert.deepStrictEqual(mfm.parse(input), output); + }); + + it('ignore a italic syntax if the before char is neither a space nor an LF', () => { + const input = 'before*abc*after'; + const output = [TEXT('before*abc*after')]; + assert.deepStrictEqual(mfm.parse(input), output); + }); + }); + + describe('italic alt 2', () => { + it('basic', () => { + const input = '_abc_'; + const output = [ + ITALIC([ + TEXT('abc') + ]) + ]; + assert.deepStrictEqual(mfm.parse(input), output); + }); + + it('basic 2', () => { + const input = 'before _abc_ after'; + const output = [ + TEXT('before '), + ITALIC([ + TEXT('abc') + ]), + TEXT(' after') + ]; + assert.deepStrictEqual(mfm.parse(input), output); + }); + + it('ignore a italic syntax if the before char is neither a space nor an LF', () => { + const input = 'before_abc_after'; + const output = [TEXT('before_abc_after')]; + assert.deepStrictEqual(mfm.parse(input), output); + }); }); // strike -- GitLab