39 lines
1.4 KiB
JavaScript
39 lines
1.4 KiB
JavaScript
var assert = require('assert');
|
|
|
|
var Utils = require('../src/utils.js').Utils;
|
|
|
|
describe('Utils', function() {
|
|
describe('escape', function() {
|
|
it('should escape & with &', function() {
|
|
var result = Utils.escape('&');
|
|
assert.equal('&', result);
|
|
});
|
|
it('should escape < with <', function() {
|
|
var result = Utils.escape('<');
|
|
assert.equal('<', result);
|
|
});
|
|
it('should escape > with >', function() {
|
|
var result = Utils.escape('>');
|
|
assert.equal('>', result);
|
|
});
|
|
it('should escape a string with multiple problematic characters', function() {
|
|
var result = Utils.escape('<a href="#">\tlink text</a>');
|
|
var expected = '<a href="#"> link text</a>';
|
|
assert.equal(expected, result);
|
|
});
|
|
});
|
|
describe('convertWhiteSpaceToNonBreakingSpace', function() {
|
|
it('should escape 1 whitespaces with ', function() {
|
|
var result = Utils.convertWhiteSpaceToNonBreakingSpace(' ');
|
|
assert.equal(' ', result);
|
|
});
|
|
it('should escape 2 whitespaces with ', function() {
|
|
var result = Utils.convertWhiteSpaceToNonBreakingSpace(' ');
|
|
assert.equal(' ', result);
|
|
});
|
|
it('should escape 4 whitespaces with ', function() {
|
|
var result = Utils.convertWhiteSpaceToNonBreakingSpace(' ');
|
|
assert.equal(' ', result);
|
|
});
|
|
});
|
|
});
|