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
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
smith/arm:smith/415-chat-test-ts-proves-a-timed-mute-survive → main 1 commit fork
1 file
changed +14
−0
Software/so101/src/chat.test.ts +14
| @@ -75,6 +75,20 @@ describe("chat", () => { | ||
| 75 | 75 | expect(again.post(bob, "hi").text).toBe("hi"); |
| 76 | 76 | }); |
| 77 | 77 | |
| 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 | ||
| 78 | 92 | test("an old-format file loads as a mute for good", async () => { |
| 79 | 93 | const old = join(mkdtempSync(join(tmpdir(), "chat-")), "chat.json"); |
| 80 | 94 | await Bun.write(old, JSON.stringify({ messages: [], muted: { c: "carol" } })); |
new above
offline