diff2html/src/__tests__/utils-tests.ts

24 lines
807 B
TypeScript
Raw Normal View History

2019-10-12 21:45:49 +00:00
import { escapeForHtml } from "../utils";
describe("Utils", function() {
describe("escape", function() {
it("should escape & with &", function() {
2019-10-12 21:45:49 +00:00
const result = escapeForHtml("&");
expect("&").toEqual(result);
});
it("should escape < with &lt;", function() {
2019-10-12 21:45:49 +00:00
const result = escapeForHtml("<");
expect("&lt;").toEqual(result);
});
it("should escape > with &gt;", function() {
2019-10-12 21:45:49 +00:00
const result = escapeForHtml(">");
expect("&gt;").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>');
const expected = "&lt;a href=&quot;#&quot;&gt;\tlink text&lt;&#x2F;a&gt;";
expect(expected).toEqual(result);
});
});
});