chore(codestyle): cleanup and reformat

This commit is contained in:
Bastian Ike
2022-09-13 11:18:36 +02:00
committed by Bastian
parent 6081f1edbb
commit 37c43712d1
56 changed files with 1142 additions and 560 deletions

View File

@@ -2,17 +2,22 @@ import { sanitize } from "./sanitize";
describe("sanitize", () => {
it("should sanitize the string input to HTML output", () => {
let res = sanitize('foo');
let res = sanitize("foo");
expect(res.__html).toEqual("foo");
res = sanitize('<a href="https://example.org">Example.org</a>');
expect(res.__html).toEqual("<a href=\"https://example.org\">Example.org</a>");
expect(res.__html).toEqual('<a href="https://example.org">Example.org</a>');
});
it("should not sanitize not allowed tags", () => {
let res = sanitize('Before <iframe src="https://example.org"></iframe> After');
let res = sanitize(
'Before <iframe src="https://example.org"></iframe> After'
);
expect(res.__html).toEqual("Before After");
});
it("should accept options for rendering", () => {
let res = sanitize('<a href="https://example.org" target="_blank">Example.org</a>', { allowedAttributes: { a: ['href']}});
expect(res.__html).toEqual("<a href=\"https://example.org\">Example.org</a>");
let res = sanitize(
'<a href="https://example.org" target="_blank">Example.org</a>',
{ allowedAttributes: { a: ["href"] } }
);
expect(res.__html).toEqual('<a href="https://example.org">Example.org</a>');
});
});