From 81ae091b8f0002610a53355ce3dbf7b4b9c2a384 Mon Sep 17 00:00:00 2001 From: Nisemono Date: Mon, 4 Dec 2023 15:55:30 +0800 Subject: [PATCH] Add test cases for highlightRule --- .../highlight/HightlightRule.test.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/core/test/unit/lib/markdown-it/highlight/HightlightRule.test.ts b/packages/core/test/unit/lib/markdown-it/highlight/HightlightRule.test.ts index eb53ac5e5c..3323b4b74c 100644 --- a/packages/core/test/unit/lib/markdown-it/highlight/HightlightRule.test.ts +++ b/packages/core/test/unit/lib/markdown-it/highlight/HightlightRule.test.ts @@ -59,12 +59,25 @@ describe('shouldApplyHighlight', () => { }); describe('getHighlightType', () => { - const rules = HighlightRule.parseAllRules('3,4[1:5]', 0, 'line1\nline2\nline3\nline4\nline5'); - const wholeLineRule = rules[0]; + const rules = HighlightRule.parseAllRules( + '3,4[1:5],1[:]-2, 6-8', 0, 'line1\nline2\nline3\nline4\nline5\nline6\nline7\nline8', + ); + const wholeTextRule = rules[0]; const partialTextRule = rules[1]; + const wholeLinesRule = rules[2]; + const wholeTextsRule = rules[3]; + + test('returns WholeLine for two lines', () => { + expect(wholeLinesRule.getHighlightType(1).highlightType).toBe(HIGHLIGHT_TYPES.WholeLine); + expect(wholeLinesRule.getHighlightType(2).highlightType).toBe(HIGHLIGHT_TYPES.WholeLine); + }); + + test('returns WholeText for in between lines', () => { + expect(wholeTextsRule.getHighlightType(7).highlightType).toBe(HIGHLIGHT_TYPES.WholeText); + }); test('returns WholeText for single line', () => { - const { highlightType } = wholeLineRule.getHighlightType(3); + const { highlightType } = wholeTextRule.getHighlightType(3); expect(highlightType).toBe(HIGHLIGHT_TYPES.WholeText); });