2019-10-12 21:45:49 +00:00
|
|
|
import { escapeForHtml } from "../utils";
|
2019-10-06 20:04:33 +00:00
|
|
|
|
|
|
|
|
describe("Utils", function() {
|
|
|
|
|
describe("escape", function() {
|
|
|
|
|
it("should escape & with &", function() {
|
2019-10-12 21:45:49 +00:00
|
|
|
const result = escapeForHtml("&");
|
2019-10-06 20:04:33 +00:00
|
|
|
expect("&").toEqual(result);
|
|
|
|
|
});
|
|
|
|
|
it("should escape < with <", function() {
|
2019-10-12 21:45:49 +00:00
|
|
|
const result = escapeForHtml("<");
|
2019-10-06 20:04:33 +00:00
|
|
|
expect("<").toEqual(result);
|
|
|
|
|
});
|
|
|
|
|
it("should escape > with >", function() {
|
2019-10-12 21:45:49 +00:00
|
|
|
const result = escapeForHtml(">");
|
2019-10-06 20:04:33 +00:00
|
|
|
expect(">").toEqual(result);
|
|
|
|
|
});
|
|
|
|
|
it("should escape a string with multiple problematic characters", function() {
|
2019-10-12 21:45:49 +00:00
|
|
|
const result = escapeForHtml('<a href="#">\tlink text</a>');
|
2019-10-06 20:04:33 +00:00
|
|
|
const expected = "<a href="#">\tlink text</a>";
|
|
|
|
|
expect(expected).toEqual(result);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|