Skip to content

Commit

Permalink
fix(test): ensure parsed content after rendering matches the original
Browse files Browse the repository at this point in the history
- sanitized strings are skipped

Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Nov 19, 2024
1 parent 1a831ef commit f62f921
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/unit/mixins/richEditor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ describe('richEditor.js', () => {
const output = editor.vm.renderContent(input)

expect(output).toEqual('hard<br>break')

const parsedOutput = editor.vm.parseContent(output)
expect(parsedOutput).toEqual(input)
})

it('no duplicated ampersand (from Linkify)', () => {
Expand All @@ -37,6 +40,9 @@ describe('richEditor.js', () => {
const output = editor.vm.renderContent(input)

expect(output).toEqual('hello &amp;')

const parsedOutput = editor.vm.parseContent(output)
expect(parsedOutput).toEqual(input)
})

it('keeps mentions without user data', () => {
Expand All @@ -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', () => {
Expand All @@ -66,6 +75,9 @@ describe('richEditor.js', () => {
expect(output).toMatch(/^hello <span.+role="heading" title="J. Doe".+\/span>!<br>how are you\?$/)
expect(output).not.toMatch(/[\n\t]/gmi)
expect(output).not.toMatch(/>\s+</g)

const parsedOutput = editor.vm.parseContent(output)
expect(parsedOutput).toEqual(input)
})

it('keeps adjacent mentions with user data', () => {
Expand All @@ -91,6 +103,9 @@ describe('richEditor.js', () => {
const output = editor.vm.renderContent(input)

expect(output).toMatch(/^hello <span.+role="heading" title="J. Doe".+\/span> <span.+role="heading" title="J. Guest".+\/span>! how are you\?$/)

const parsedOutput = editor.vm.parseContent(output)
expect(parsedOutput).toEqual(input)
})

it('keep mentions with special characters', () => {
Expand Down Expand Up @@ -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])
}
})
})
Expand Down

0 comments on commit f62f921

Please sign in to comment.