The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { scopeThreadRef } from "@t3tools/client-runtime/environment"; |
| 2 | import { EnvironmentId, ThreadId } from "@t3tools/contracts"; |
| 3 | import { describe, expect, it } from "vite-plus/test"; |
| 4 | |
| 5 | import { registerSettleAndAdvance, settleAndAdvance } from "./settleAndAdvance"; |
| 6 | |
| 7 | const threadRef = scopeThreadRef( |
| 8 | EnvironmentId.make("environment-local"), |
| 9 | ThreadId.make("thread-1"), |
| 10 | ); |
| 11 | |
| 12 | describe("settleAndAdvance", () => { |
| 13 | it("keeps a remounted sidebar's handler when the old one unmounts late", () => { |
| 14 | const settledBy: string[] = []; |
| 15 | const unregisterOld = registerSettleAndAdvance(() => settledBy.push("old")); |
| 16 | const unregisterNew = registerSettleAndAdvance(() => settledBy.push("new")); |
| 17 | unregisterOld(); |
| 18 | |
| 19 | expect(settleAndAdvance(threadRef)).toBe(true); |
| 20 | expect(settledBy).toEqual(["new"]); |
| 21 | unregisterNew(); |
| 22 | expect(settleAndAdvance(threadRef)).toBe(false); |
| 23 | }); |
| 24 | }); |