| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { isLegalDocumentUrl } from "./legal-document-url"; |
| 4 | |
| 5 | describe("isLegalDocumentUrl", () => { |
| 6 | it.each([ |
| 7 | "https://t3.codes/legal", |
| 8 | "https://t3.codes/legal/", |
| 9 | "https://t3.codes/privacy-policy?source=app", |
| 10 | "https://t3.codes/terms-of-service#updates", |
| 11 | "https://t3.codes/security-policy", |
| 12 | ])("allows a configured legal document: %s", (url) => { |
| 13 | expect(isLegalDocumentUrl(url)).toBe(true); |
| 14 | }); |
| 15 | |
| 16 | it.each([ |
| 17 | "https://t3.codes/download", |
| 18 | "https://example.com/legal", |
| 19 | "javascript:alert(1)", |
| 20 | "not-a-url", |
| 21 | ])("rejects a URL outside the legal-document allowlist: %s", (url) => { |
| 22 | expect(isLegalDocumentUrl(url)).toBe(false); |
| 23 | }); |
| 24 | }); |