From f81aca3c7d37118aa3ed3b1ecbcae99ca99bd8eb Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 16 Apr 2024 13:17:07 +0200 Subject: [PATCH] add tests --- __tests__/ExpensiMark-HTMLToText-test.js | 32 +++++++++++++++++++++++- __tests__/ExpensiMark-Markdown-test.js | 32 +++++++++++++++++++++++- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/__tests__/ExpensiMark-HTMLToText-test.js b/__tests__/ExpensiMark-HTMLToText-test.js index 7a65d877..197010d8 100644 --- a/__tests__/ExpensiMark-HTMLToText-test.js +++ b/__tests__/ExpensiMark-HTMLToText-test.js @@ -133,7 +133,7 @@ test('Test remove style tag', () => { expect(parser.htmlToText(testString)).toBe('a text'); }); -test('Mention html to text', () => { +test('Mention user html to text', () => { let testString = '@user@domain.com'; expect(parser.htmlToText(testString)).toBe('@user@domain.com'); @@ -145,6 +145,36 @@ test('Mention html to text', () => { testString = '@user@DOMAIN.com'; expect(parser.htmlToText(testString)).toBe('@user@DOMAIN.com'); + + const extras = { + "accountIdToName": { + "1234": "@user@domain.com" + } + } + testString = ''; + expect(parser.htmlToText(testString, extras)).toBe('@user@domain.com'); +}); + +test('Mention report html to text', () => { + let testString = '#room-name'; + expect(parser.htmlToText(testString)).toBe('#room-name'); + + testString = '#ROOM-NAME'; + expect(parser.htmlToText(testString)).toBe('#ROOM-NAME'); + + testString = '#ROOM-name'; + expect(parser.htmlToText(testString)).toBe('#ROOM-name'); + + testString = '#room-NAME'; + expect(parser.htmlToText(testString)).toBe('#room-NAME'); + + const extras = { + "reportIdToName": { + "1234": "#room-name" + } + } + testString = ''; + expect(parser.htmlToText(testString, extras)).toBe('#room-name'); }); test('Test replacement for tags', () => { diff --git a/__tests__/ExpensiMark-Markdown-test.js b/__tests__/ExpensiMark-Markdown-test.js index cd68a4b8..2f2b5a0b 100644 --- a/__tests__/ExpensiMark-Markdown-test.js +++ b/__tests__/ExpensiMark-Markdown-test.js @@ -743,7 +743,7 @@ test('Linebreak should be remained for text between code block', () => { }); }); -test('Mention html to markdown', () => { +test('Mention user html to markdown', () => { let testString = '@user@domain.com'; expect(parser.htmlToMarkdown(testString)).toBe('@user@domain.com'); @@ -755,6 +755,36 @@ test('Mention html to markdown', () => { testString = '@user@DOMAIN.com'; expect(parser.htmlToMarkdown(testString)).toBe('@user@DOMAIN.com'); + + const extras = { + "accountIdToName": { + "1234": "@user@domain.com" + } + } + testString = ''; + expect(parser.htmlToMarkdown(testString, extras)).toBe('@user@domain.com'); +}); + +test('Mention report html to markdown', () => { + let testString = '#room-name'; + expect(parser.htmlToMarkdown(testString)).toBe('#room-name'); + + testString = '#ROOM-NAME'; + expect(parser.htmlToMarkdown(testString)).toBe('#ROOM-NAME'); + + testString = '#ROOM-name'; + expect(parser.htmlToMarkdown(testString)).toBe('#ROOM-name'); + + testString = '#room-NAME'; + expect(parser.htmlToMarkdown(testString)).toBe('#room-NAME'); + + const extras = { + "reportIdToName": { + "1234": "#room-name" + } + } + testString = ''; + expect(parser.htmlToMarkdown(testString, extras)).toBe('#room-name'); }); describe('Image tag conversion to markdown', () => {