mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-17 03:31:52 +00:00
jest-codemods tests/lib
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
/**
|
||||
* @fileoverview Unit test for browser/lib/htmlTextHelper
|
||||
*/
|
||||
const test = require('ava')
|
||||
const htmlTextHelper = require('browser/lib/htmlTextHelper')
|
||||
|
||||
// Unit test
|
||||
test('htmlTextHelper#decodeEntities should return encoded text (string)', t => {
|
||||
test('htmlTextHelper#decodeEntities should return encoded text (string)', () => {
|
||||
// [input, expected]
|
||||
const testCases = [
|
||||
['<a href=', '<a href='],
|
||||
@@ -18,11 +17,11 @@ test('htmlTextHelper#decodeEntities should return encoded text (string)', t => {
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase
|
||||
t.is(htmlTextHelper.decodeEntities(input), expected, `Test for decodeEntities() input: ${input} expected: ${expected}`)
|
||||
expect(htmlTextHelper.decodeEntities(input)).toBe(expected)
|
||||
})
|
||||
})
|
||||
|
||||
test('htmlTextHelper#decodeEntities() should return decoded text (string)', t => {
|
||||
test('htmlTextHelper#decodeEntities() should return decoded text (string)', () => {
|
||||
// [input, expected]
|
||||
const testCases = [
|
||||
['<a href=', '<a href='],
|
||||
@@ -34,12 +33,12 @@ test('htmlTextHelper#decodeEntities() should return decoded text (string)', t =>
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [input, expected] = testCase
|
||||
t.is(htmlTextHelper.encodeEntities(input), expected, `Test for encodeEntities() input: ${input} expected: ${expected}`)
|
||||
expect(htmlTextHelper.encodeEntities(input)).toBe(expected)
|
||||
})
|
||||
})
|
||||
|
||||
// Integration test
|
||||
test(t => {
|
||||
test(() => {
|
||||
const testCases = [
|
||||
'var test = \'test\'',
|
||||
'<a href=\'https://boostnote.io\'>Boostnote',
|
||||
@@ -49,6 +48,6 @@ test(t => {
|
||||
testCases.forEach(testCase => {
|
||||
const encodedText = htmlTextHelper.encodeEntities(testCase)
|
||||
const decodedText = htmlTextHelper.decodeEntities(encodedText)
|
||||
t.is(decodedText, testCase, 'Integration test through encodedText() and decodedText()')
|
||||
expect(decodedText).toBe(testCase)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user