import { describe, expect, it } from "vitest"; import { cooldownAppliesTo } from "./cooldown"; describe("resend cooldown keying (SD-0001 ยง5.2, INV-3; bug #20)", () => { it("no cooldown running -> send not blocked", () => { expect(cooldownAppliesTo("a@example.com", null, 0)).toBe(false); }); it("cooldown running for the same address -> blocked", () => { expect(cooldownAppliesTo("a@example.com", "a@example.com", 31)).toBe(true); }); it("same address modulo case/whitespace -> still blocked", () => { expect(cooldownAppliesTo(" A@Example.COM ", "a@example.com", 31)).toBe(true); }); it("cooldown running but the input is a different address -> not blocked", () => { expect(cooldownAppliesTo("right@example.com", "wrong@example.com", 31)).toBe(false); }); it("cooldown expired -> not blocked even for the same address", () => { expect(cooldownAppliesTo("a@example.com", "a@example.com", 0)).toBe(false); }); });