mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
rename files to suit Jest
This commit is contained in:
72
tests/lib/escapeHtmlCharacters.test.js
Normal file
72
tests/lib/escapeHtmlCharacters.test.js
Normal file
@@ -0,0 +1,72 @@
|
||||
const { escapeHtmlCharacters } = require('browser/lib/utils')
|
||||
|
||||
test('escapeHtmlCharacters should return the original string if nothing needed to escape', () => {
|
||||
const input = 'Nothing to be escaped'
|
||||
const expected = 'Nothing to be escaped'
|
||||
const actual = escapeHtmlCharacters(input)
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
|
||||
test('escapeHtmlCharacters should skip code block if that option is enabled', () => {
|
||||
const input = ` <no escape>
|
||||
<escapeMe>`
|
||||
const expected = ` <no escape>
|
||||
<escapeMe>`
|
||||
const actual = escapeHtmlCharacters(input, { detectCodeBlock: true })
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
|
||||
test('escapeHtmlCharacters should NOT skip character not in code block but start with 4 spaces', () => {
|
||||
const input = '4 spaces &'
|
||||
const expected = '4 spaces &'
|
||||
const actual = escapeHtmlCharacters(input, { detectCodeBlock: true })
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
|
||||
test('escapeHtmlCharacters should NOT skip code block if that option is NOT enabled', () => {
|
||||
const input = ` <no escape>
|
||||
<escapeMe>`
|
||||
const expected = ` <no escape>
|
||||
<escapeMe>`
|
||||
const actual = escapeHtmlCharacters(input)
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
|
||||
test("escapeHtmlCharacters should NOT escape & character if it's a part of an escaped character", () => {
|
||||
const input = 'Do not escape & or " but do escape &'
|
||||
const expected = 'Do not escape & or " but do escape &'
|
||||
const actual = escapeHtmlCharacters(input)
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
|
||||
test('escapeHtmlCharacters should skip char if in code block', () => {
|
||||
const input = `
|
||||
\`\`\`
|
||||
<dontescapeme>
|
||||
\`\`\`
|
||||
das<das>dasd
|
||||
dasdasdasd
|
||||
\`\`\`
|
||||
<dontescapeme>
|
||||
\`\`\`
|
||||
`
|
||||
const expected = `
|
||||
\`\`\`
|
||||
<dontescapeme>
|
||||
\`\`\`
|
||||
das<das>dasd
|
||||
dasdasdasd
|
||||
\`\`\`
|
||||
<dontescapeme>
|
||||
\`\`\`
|
||||
`
|
||||
const actual = escapeHtmlCharacters(input, { detectCodeBlock: true })
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
|
||||
test('escapeHtmlCharacters should return the correct result', () => {
|
||||
const input = '& < > " \''
|
||||
const expected = '& < > " ''
|
||||
const actual = escapeHtmlCharacters(input)
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
Reference in New Issue
Block a user