From ff377994f41215c678feda7497168fd38074f817 Mon Sep 17 00:00:00 2001 From: Robert Kozik Date: Sun, 25 Feb 2024 00:19:23 +0100 Subject: [PATCH] add tests for nested quotes --- __tests__/ExpensiMark-HTML-test.js | 59 +++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/__tests__/ExpensiMark-HTML-test.js b/__tests__/ExpensiMark-HTML-test.js index 50e98189..97018421 100644 --- a/__tests__/ExpensiMark-HTML-test.js +++ b/__tests__/ExpensiMark-HTML-test.js @@ -1828,4 +1828,61 @@ test('Test italic/bold/strikethrough markdown to keep consistency', () => { testString = '~This~is~strikethrough~test~~~~'; resultString = 'This~is~strikethrough~test~~~'; expect(parser.replace(testString)).toBe(resultString); -}); \ No newline at end of file +}); + + +describe('multi-level blockquote', () => { + test('test max level of blockquote (3)', () => { + const quoteTestStartString = '>>>>> Hello world'; + const quoteTestReplacedString = '
>> Hello world
'; + + expect(parser.replace(quoteTestStartString)).toBe(quoteTestReplacedString); + }); + test('multi-level blockquote with single space', () => { + const quoteTestStartString = '> > > Hello world'; + const quoteTestReplacedString = '
Hello world
'; + + expect(parser.replace(quoteTestStartString)).toBe(quoteTestReplacedString); + }); + test('multi-level blockquote with multiple spaces', () => { + const quoteTestStartString = '> > > Hello world'; + const quoteTestReplacedString = '
Hello world
'; + + expect(parser.replace(quoteTestStartString)).toBe(quoteTestReplacedString); + }); + + test('multi-level blockquote with mixed spaces', () => { + const quoteTestStartString = '> > > Hello world'; + const quoteTestReplacedString = '
Hello world
'; + + expect(parser.replace(quoteTestStartString)).toBe(quoteTestReplacedString); + }); + + test('multi-level blockquote with diffrent syntax', () => { + const quoteTestStartString = '> > _Hello_ *world*'; + const quoteTestReplacedString = '
Hello world
'; + + expect(parser.replace(quoteTestStartString)).toBe(quoteTestReplacedString); + }); + + test('multi-level blockquote with nested heading', () => { + const quoteTestStartString = '> > # Hello world'; + const quoteTestReplacedString = '

Hello world

'; + + expect(parser.replace(quoteTestStartString)).toBe(quoteTestReplacedString); + }); + + test('multiline multi-level blockquote', () => { + const quoteTestStartString = '> > Hello my\n> > beautiful\n> > world\n'; + const quoteTestReplacedString = '
Hello my
beautiful
world
'; + + expect(parser.replace(quoteTestStartString)).toBe(quoteTestReplacedString); + }); + + test('multiline blockquote with diffrent levels', () => { + const quoteTestStartString = '> > > Hello my\n> > beautiful\n> world\n'; + const quoteTestReplacedString = '
Hello my
beautiful
world
'; + + expect(parser.replace(quoteTestStartString)).toBe(quoteTestReplacedString); + }); +});