wsemi
Version:
A support package for web developer.
80 lines (64 loc) • 2.59 kB
JavaScript
import assert from 'assert'
import htmlDecode from '../src/htmlDecode.mjs'
describe(`htmlDecode`, function() {
it(`should return 'foo&bar' when input 'foo&bar'`, function() {
let r = htmlDecode('foo&bar')
let rr = `foo&bar`
assert.strict.deepStrictEqual(r, rr)
})
it(`should return 'foo © bar ≠ baz 𝌆 qux' bar ≠ baz 𝌆 qux' when input 'foo © bar ≠ baz 𝌆 qux'`, function() {
let r = htmlDecode('foo © bar ≠ baz 𝌆 qux')
let rr = `foo © bar ≠ baz 𝌆 qux`
assert.strict.deepStrictEqual(r, rr)
})
it(`should return '<img src="x"" onerror="prompt(1)">' onerror="prompt(1)">' when input '<img src="x"" onerror="prompt(1)">'`, function() {
let r = htmlDecode('<img src="x"" onerror="prompt(1)">')
let rr = `<img src="x"" onerror="prompt(1)">`
assert.strict.deepStrictEqual(r, rr)
})
it(`should return '25' when input '25'`, function() {
let r = htmlDecode('25')
let rr = '25'
assert.strict.deepStrictEqual(r, rr)
})
it(`should return '1.25' when input '1.25'`, function() {
let r = htmlDecode('1.25')
let rr = '1.25'
assert.strict.deepStrictEqual(r, rr)
})
it(`should return '' when input 2.25`, function() {
let r = htmlDecode(2.25)
let rr = ''
assert.strict.deepStrictEqual(r, rr)
})
it(`should return '' when input ''`, function() {
let r = htmlDecode('')
let rr = ''
assert.strict.deepStrictEqual(r, rr)
})
it(`should return '' when input []`, function() {
let r = htmlDecode([])
let rr = ''
assert.strict.deepStrictEqual(r, rr)
})
it(`should return '' when input {}`, function() {
let r = htmlDecode({})
let rr = ''
assert.strict.deepStrictEqual(r, rr)
})
it(`should return '' when input null`, function() {
let r = htmlDecode(null)
let rr = ''
assert.strict.deepStrictEqual(r, rr)
})
it(`should return '' when input undefined`, function() {
let r = htmlDecode(undefined)
let rr = ''
assert.strict.deepStrictEqual(r, rr)
})
it(`should return '' when input NaN`, function() {
let r = htmlDecode(NaN)
let rr = ''
assert.strict.deepStrictEqual(r, rr)
})
})