awesome-string
Version:
The ultimate JavaScript string library
35 lines (30 loc) • 1.71 kB
JavaScript
import as from '../awesome-string';
import { expect } from 'chai';
import { PRINTABLE_ASCII } from '../const';
describe('unescapeHtml', function() {
it('should return the unescaped', function() {
expect(as.unescapeHtml('<>&"'`')).to.be.equal('<>&"\'`');
expect(as.unescapeHtml('<p>wonderful world</p>')).to.be.equal('<p>wonderful world</p>');
expect(as.unescapeHtml('<p>wonderful world</p>')).to.be.equal('<p>wonderful world</p>');
expect(as.unescapeHtml('<p>wonderful world</p>')).to.be.equal('<p>wonderful world</p>');
expect(as.unescapeHtml('<p>wonderful world</p>')).to.be.equal('<p>wonderful world</p>');
expect(as.unescapeHtml('< < < > > > & & & " " " ' ' ` `'))
.to.be.equal('< < < > > > & & & " " " \' \' ` `');
expect(as.unescapeHtml(' !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'))
.to.be.equal(PRINTABLE_ASCII);
expect(as.unescapeHtml('<>&"\'`')).to.be.equal('<>&"\'`');
});
it('should return the unescaped string representation of an object', function() {
expect(as.unescapeHtml(['<span>'])).to.be.equal('<span>');
expect(as.unescapeHtml({
toString: function() {
return '<script>';
}
})).to.be.equal('<script>');
});
it('should return an empty string for null or undefined', function() {
expect(as.unescapeHtml()).to.be.equal('');
expect(as.unescapeHtml(undefined)).to.be.equal('');
expect(as.unescapeHtml(null)).to.be.equal('');
});
});