1
0
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:
amedora
2019-08-07 14:17:48 +09:00
parent 606be4304d
commit ffb2603485
12 changed files with 92 additions and 104 deletions

View File

@@ -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 = [
['&lt;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=', '&lt;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)
})
})