libdom
Version:
Lean Browser Library for typical DOM operations
31 lines (27 loc) • 1.3 kB
JavaScript
;
describe(`Decodes HTML entities in String subject into HTML special
characters returning the original/raw String value of
the subject using xmlDecode(subject:String).`,
() => {
var xmlDecode = global.libdom.xmlDecode;
it(`1. Should not accept non String as first parameter [subject]
and throws an error instead.`,
() => {
expect(() => xmlDecode(99)).toThrow();
expect(() => xmlDecode([99])).toThrow();
expect(() => xmlDecode({ tag: "<h1></h1>" })).toThrow();
expect(() => xmlDecode(undefined)).toThrow();
expect(() => xmlDecode(false)).toThrow();
});
it(`2. Should accept String as first parameter [subject] and returns
the decoded value.`,
() => {
expect(xmlDecode('<h1>Title</h1>')).
toBe('<h1>Title</h1>');
expect(xmlDecode('<a href="/home" title='+
'"Home">Home</a>')).
toBe('<a href="/home" title="Home">Home</a>');
expect(xmlDecode('Just a string!')).
toBe(`Just a string!`);
});
});