@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

main
ts 32 lines 1.41 KB
Raw
1 import { EnvironmentId } from "@t3tools/contracts";
2 import { describe, expect, it } from "vite-plus/test";
3
4 import { toggleUsageEnvironment } from "./usageEnvironmentSelection";
5
6 const a = EnvironmentId.make("a");
7 const b = EnvironmentId.make("b");
8 const c = EnvironmentId.make("c");
9 const removed = EnvironmentId.make("removed");
10 const environments = [a, b, c].map((environmentId) => ({ environmentId }));
11
12 describe("usage environment selection", () => {
13 it("can exclude an environment from all, then select all again", () => {
14 const selected = toggleUsageEnvironment(null, environments, b);
15 expect(selected).toEqual(new Set([a, c]));
16 expect(toggleUsageEnvironment(selected, environments, b)).toBeNull();
17 });
18
19 it("does not count removed IDs toward selecting all current environments", () => {
20 expect(toggleUsageEnvironment(new Set([a, removed]), environments, b)).toEqual(new Set([a, b]));
21 });
22
23 it("returns to all mode despite stale IDs when every current environment is selected", () => {
24 expect(toggleUsageEnvironment(new Set([a, c, removed]), environments, b)).toBeNull();
25 });
26
27 it("includes newly connected environments only in all mode", () => {
28 const expanded = [...environments, { environmentId: removed }];
29 expect(toggleUsageEnvironment(null, expanded, a)).toEqual(new Set([b, c, removed]));
30 expect(toggleUsageEnvironment(new Set([a, b, c]), expanded, a)).toEqual(new Set([b, c]));
31 });
32 });