Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

workbenchthis machine

chat.test.ts proves a timed mute survives a reload and still ends on time - test only #420

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

smith/arm:smith/415-chat-test-ts-proves-a-timed-mute-survive → main 1 commit fork

  • Merged. smith/415-chat-test-ts-proves-a-timed-mute-survive was merged into main as 472bf14.

Review

Sign in to review this change.
1 file changed +14 −0
Software/so101/src/chat.test.ts +14
@@ -75,6 +75,20 @@ describe("chat", () => {
7575 expect(again.post(bob, "hi").text).toBe("hi");
7676 });
7777
78 test("a timed mute survives a reload and still ends on time", () => {
79 const min = 60_000;
80 let clock = 0;
81 const file = join(mkdtempSync(join(tmpdir(), "chat-")), "chat.json");
82 new Chat({ file, now: () => clock }).mute("a", "alice", 10 * min);
83 clock = 5 * min;
84 const again = new Chat({ file, now: () => clock });
85 expect(again.muted.get("a")).toBe("alice");
86 expect(() => again.post(alice, "hi")).toThrow(/muted/);
87 clock = 10 * min + 1000;
88 expect(again.post(alice, "hi").text).toBe("hi");
89 expect(again.muted.has("a")).toBe(false);
90 });
91
7892 test("an old-format file loads as a mute for good", async () => {
7993 const old = join(mkdtempSync(join(tmpdir(), "chat-")), "chat.json");
8094 await Bun.write(old, JSON.stringify({ messages: [], muted: { c: "carol" } }));

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs