Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

environmentAtomList.test.ts

24 lines1013 Bytes

1import { EnvironmentId } from "@t3tools/contracts";
2import { Atom, AtomRegistry } from "effect/reactivity";
3import { describe, expect, it } from "vite-plus/test";
4​
5import { environmentAtomList, environmentIdsKey } from "./environmentAtomList";
6​
7const counts = Atom.family((environmentId: EnvironmentId) => Atom.make(environmentId.length));
8const countsList = environmentAtomList("test-counts", counts);
9​
10describe("environmentAtomList", () => {
11 it("returns the same atom and snapshot for an equal id list", () => {
12 const registry = AtomRegistry.make();
13 const first = countsList(
14 environmentIdsKey([EnvironmentId.make("a"), EnvironmentId.make("bb")]),
15 );
16 const second = countsList(
17 environmentIdsKey([EnvironmentId.make("a"), EnvironmentId.make("bb")]),
18 );
19 expect(second).toBe(first);
20 expect(registry.get(first)).toEqual([1, 2]);
21 expect(registry.get(second)).toBe(registry.get(first));
22 expect(registry.get(countsList(environmentIdsKey([])))).toEqual([]);
23 });
24});