chore(codestyle): cleanup and reformat
This commit is contained in:
@@ -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>');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user