24 lines
805 B
JavaScript
24 lines
805 B
JavaScript
|
|
const Utils = require("../utils.js").Utils;
|
||
|
|
|
||
|
|
describe("Utils", function() {
|
||
|
|
describe("escape", function() {
|
||
|
|
it("should escape & with &", function() {
|
||
|
|
const result = Utils.escape("&");
|
||
|
|
expect("&").toEqual(result);
|
||
|
|
});
|
||
|
|
it("should escape < with <", function() {
|
||
|
|
const result = Utils.escape("<");
|
||
|
|
expect("<").toEqual(result);
|
||
|
|
});
|
||
|
|
it("should escape > with >", function() {
|
||
|
|
const result = Utils.escape(">");
|
||
|
|
expect(">").toEqual(result);
|
||
|
|
});
|
||
|
|
it("should escape a string with multiple problematic characters", function() {
|
||
|
|
const result = Utils.escape('<a href="#">\tlink text</a>');
|
||
|
|
const expected = "<a href="#">\tlink text</a>";
|
||
|
|
expect(expected).toEqual(result);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|