mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 10:16:26 +00:00
rename files to suit Jest
This commit is contained in:
53
tests/lib/html-text-helper.test.js
Normal file
53
tests/lib/html-text-helper.test.js
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @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=', '<a href='],
|
||||
['var test = 'test'', 'var test = \'test\''],
|
||||
['<a href='https://boostnote.io'>Boostnote', '<a href=\'https://boostnote.io\'>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 = [
|
||||
['<a href=', '<a href='],
|
||||
['var test = \'test\'', 'var test = 'test''],
|
||||
['<a href=\'https://boostnote.io\'>Boostnote', '<a href='https://boostnote.io'>Boostnote'],
|
||||
['<?php\n var = \'hoge\';', '<?php\n var = 'hoge';'],
|
||||
['a$\'', 'a$'']
|
||||
]
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase
|
||||
expect(htmlTextHelper.encodeEntities(input)).toBe(expected)
|
||||
})
|
||||
})
|
||||
|
||||
// Integration test
|
||||
test(() => {
|
||||
const testCases = [
|
||||
'var test = \'test\'',
|
||||
'<a href=\'https://boostnote.io\'>Boostnote',
|
||||
'<Component styleName=\'test\' />'
|
||||
]
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const encodedText = htmlTextHelper.encodeEntities(testCase)
|
||||
const decodedText = htmlTextHelper.decodeEntities(encodedText)
|
||||
expect(decodedText).toBe(testCase)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user