/**
* @fileoverview Unit test for browser/lib/htmlTextHelper
*/
const htmlTextHelper = require('browser/lib/htmlTextHelper')
// Unit test
test('htmlTextHelper#decodeEntities should return encoded text (string)', () => {
// [input, expected]
const testCases = [
['<a href=', 'Boostnote'],
['<\\\\?php\n var = 'hoge';', '<\\\\?php\n var = \'hoge\';'],
['&', '&'],
['a$'', 'a\\$\'']
]
testCases.forEach(testCase => {
const [input, expected] = testCase
expect(htmlTextHelper.decodeEntities(input)).toBe(expected)
})
})
test('htmlTextHelper#decodeEntities() should return decoded text (string)', () => {
// [input, expected]
const testCases = [
['Boostnote', '<a href='https://boostnote.io'>Boostnote'],
[' {
const [input, expected] = testCase
expect(htmlTextHelper.encodeEntities(input)).toBe(expected)
})
})
// Integration test
test(() => {
const testCases = [
'var test = \'test\'',
'Boostnote',
''
]
testCases.forEach(testCase => {
const encodedText = htmlTextHelper.encodeEntities(testCase)
const decodedText = htmlTextHelper.decodeEntities(encodedText)
expect(decodedText).toBe(testCase)
})
})