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, 04:45 UTC
| 1 | import type { ServerProvider } from "@t3tools/contracts"; |
| 2 | import { describe, expect, it } from "vite-plus/test"; |
| 3 | |
| 4 | import { reuseProvidersIgnoringCheckedAt } from "./serverProviders.logic"; |
| 5 | |
| 6 | const models = [{ slug: "opus", name: "Opus" }]; |
| 7 | const provider = (instanceId: string, checkedAt: string, status = "ready") => |
| 8 | ({ |
| 9 | instanceId, |
| 10 | status, |
| 11 | checkedAt, |
| 12 | models, |
| 13 | versionAdvisory: { status: "current", checkedAt }, |
| 14 | }) as unknown as ServerProvider; |
| 15 | |
| 16 | describe("reuseProvidersIgnoringCheckedAt", () => { |
| 17 | it("keeps the previous list when a push only restamps checkedAt", () => { |
| 18 | const previous = [provider("claude", "a"), provider("codex", "a")]; |
| 19 | const next = [provider("claude", "b"), provider("codex", "b")]; |
| 20 | expect(reuseProvidersIgnoringCheckedAt(previous, next)).toBe(previous); |
| 21 | }); |
| 22 | |
| 23 | it("takes the new list when providers are added or reordered", () => { |
| 24 | const previous = [provider("claude", "a"), provider("codex", "a")]; |
| 25 | const reordered = [provider("codex", "b"), provider("claude", "b")]; |
| 26 | const merged = reuseProvidersIgnoringCheckedAt(previous, reordered); |
| 27 | expect(merged.map((entry) => entry.instanceId)).toEqual(["codex", "claude"]); |
| 28 | expect(merged[0]).toBe(previous[1]); |
| 29 | const added = reuseProvidersIgnoringCheckedAt(previous, [...previous, provider("cursor", "b")]); |
| 30 | expect(added).toHaveLength(3); |
| 31 | }); |
| 32 | }); |