From f62f92161fd242d9de2b1dc4b513976645cba7aa Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Tue, 19 Nov 2024 17:09:42 +0100 Subject: [PATCH] fix(test): ensure parsed content after rendering matches the original - sanitized strings are skipped Signed-off-by: Maksim Sukharev --- tests/unit/mixins/richEditor.spec.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/unit/mixins/richEditor.spec.js b/tests/unit/mixins/richEditor.spec.js index 327cb6554a..c17fc78895 100644 --- a/tests/unit/mixins/richEditor.spec.js +++ b/tests/unit/mixins/richEditor.spec.js @@ -29,6 +29,9 @@ describe('richEditor.js', () => { const output = editor.vm.renderContent(input) expect(output).toEqual('hard
break') + + const parsedOutput = editor.vm.parseContent(output) + expect(parsedOutput).toEqual(input) }) it('no duplicated ampersand (from Linkify)', () => { @@ -37,6 +40,9 @@ describe('richEditor.js', () => { const output = editor.vm.renderContent(input) expect(output).toEqual('hello &') + + const parsedOutput = editor.vm.parseContent(output) + expect(parsedOutput).toEqual(input) }) it('keeps mentions without user data', () => { @@ -45,6 +51,9 @@ describe('richEditor.js', () => { const output = editor.vm.renderContent(input) expect(output).toEqual('hello @foobar') + + const parsedOutput = editor.vm.parseContent(output) + expect(parsedOutput).toEqual(input) }) it('keeps mentions with user data', () => { @@ -66,6 +75,9 @@ describe('richEditor.js', () => { expect(output).toMatch(/^hello !
how are you\?$/) expect(output).not.toMatch(/[\n\t]/gmi) expect(output).not.toMatch(/>\s+ { @@ -91,6 +103,9 @@ describe('richEditor.js', () => { const output = editor.vm.renderContent(input) expect(output).toMatch(/^hello ! how are you\?$/) + + const parsedOutput = editor.vm.parseContent(output) + expect(parsedOutput).toEqual(input) }) it('keep mentions with special characters', () => { @@ -119,6 +134,9 @@ describe('richEditor.js', () => { for (const i in inputs) { const output = editor.vm.renderContent(inputs[i]) expect(output).toEqual(outputs[i]) + + const parsedOutput = editor.vm.parseContent(output) + expect(parsedOutput).toEqual(inputs[i]) } }) })