18 lines
559 B
TypeScript
18 lines
559 B
TypeScript
|
|
import { describe, expect, it } from "bun:test";
|
|
import { escapeHtml } from "./html";
|
|
|
|
describe("HTML Utils", () => {
|
|
it("should escape special characters", () => {
|
|
const unsafe = '<script>alert("xss")</script>';
|
|
const safe = escapeHtml(unsafe);
|
|
expect(safe).toBe("<script>alert("xss")</script>");
|
|
});
|
|
|
|
it("should handle mixed content", () => {
|
|
const unsafe = 'Hello & "World"';
|
|
const safe = escapeHtml(unsafe);
|
|
expect(safe).toBe("Hello & "World"");
|
|
});
|
|
});
|