Skip to content

Commit

Permalink
test: add sanitise test case
Browse files Browse the repository at this point in the history
  • Loading branch information
xusd320 committed Jul 19, 2024
1 parent dd3257a commit ee6761c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/index.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ function formatHtml(html) {
.replace(/\r\n/g, "\n");
}

test("should sanitise html", (t) => {
const $ = parse(
'<div class="one">first</div><body>Bad body</body><div id="two">second</div>',
);

t.is(
$.outerHtml(),
'<html><head></head><body><div class="one">first</div>Bad body<div id="two">second</div></body></html>',
);
});

test("should not change the original html structure", (t) => {
const jqueryHtml = fs.readFileSync(path.resolve(__dirname, "jquery.html"), {
encoding: "utf8",
Expand Down

0 comments on commit ee6761c

Please sign in to comment.