1import { formatPushPolicy } from "./push.ts";2import { printableNote } from "./sites.ts";34function assertEquals(actual: string, expected: string): void {5 if (actual !== expected) throw new Error(`expected ${expected}, got ${actual}`);6}78function assertStringIncludes(actual: string, expected: string): void {9 if (!actual.includes(expected)) {10 throw new Error(`expected ${JSON.stringify(actual)} to include ${JSON.stringify(expected)}`);11 }12}1314Deno.test("push feedback reports permanent password protection", () => {15 assertEquals(formatPushPolicy(null, true), "forever, password protected");16});1718Deno.test("push feedback reports finite expiry without password protection", () => {19 assertStringIncludes(20 formatPushPolicy(Math.floor(Date.now() / 1000) + 86_400, false),21 "expires in 1d, no password",22 );23});2425Deno.test("push feedback reports when visitor feedback is on", () => {26 assertEquals(formatPushPolicy(null, true, true), "forever, password protected, feedback on");27});2829Deno.test("feedback notes cannot drive the terminal", () => {30 assertEquals(printableNote("ok\x1b]0;pwned\x07\x1b[2K\tnext\nline"), "ok]0;pwned[2K\tnext\nline");31});