diff --git a/test/sanitize.test.ts b/test/sanitize.test.ts index 83eda3945..aefa3a03d 100644 --- a/test/sanitize.test.ts +++ b/test/sanitize.test.ts @@ -34,6 +34,18 @@ describe("stripHtml", () => { expect(stripHtml("<script>alert(1)</script>")).toBe("alert(1)"); expect(stripHtml("<b>Hello</b>")).toBe("Hello"); }); + it("returns plain text unchanged", () => { + expect(stripHtml("Hello World")).toBe("Hello World"); + }); + + it("decodes apostrophe entities", () => { + expect(stripHtml("it's fine")).toBe("it's fine"); + expect(stripHtml("it's fine")).toBe("it's fine"); + }); + + it("handles mixed tags and entities", () => { + expect(stripHtml("Tom & Jerry")).toBe("Tom & Jerry"); + }); }); describe("validateTextInput", () => { @@ -101,4 +113,10 @@ describe("validateTextInput", () => { error: "Name must be 5 characters or fewer", }); }); + it("strips script injection and returns ok", () => { + expect(validateTextInput("Hello", "Name")).toEqual({ + ok: true, + value: "Hello", + }); + }); });