22 lines
553 B
JavaScript
22 lines
553 B
JavaScript
import escape from '../escape'
|
|
describe('escape', () => {
|
|
const htmlEscapes = {
|
|
'&': '&',
|
|
'<': '<',
|
|
'>': '>',
|
|
'"': '"',
|
|
"'": ''',
|
|
'/': '/',
|
|
}
|
|
it('should escape each character', () => {
|
|
for (let [char, escapedChar] of Object.entries(htmlEscapes)) {
|
|
expect(escape(char)).toBe(escapedChar)
|
|
}
|
|
})
|
|
it('should escape multiple characters', () => {
|
|
expect(escape('& and < and > and " and \' and /')).toBe(
|
|
'& and < and > and " and ' and /'
|
|
)
|
|
})
|
|
})
|