1import { assert, describe, it } from "@effect/vitest";
2
3import { resolveCatalogDependencies } from "./resolve-catalog.ts";
4
5const catalog = { effect: "4.0.0-rc.115", "@clerk/backend": "3.18.1", react: "19.2.0" };
6
7describe("resolveCatalogDependencies", () => {
8 it("resolves bare, named and override-selector catalog specs like pnpm", () => {
9 assert.deepStrictEqual(
10 resolveCatalogDependencies(
11 {
12 "@clerk/backend": "catalog:",
13 "react-dom": "catalog:react",
14 "@opencode/protocol>effect": "catalog:",
15 "dbus-next>usocket": "-",
16 lodash: "4.17.21",
17 },
18 catalog,
19 "apps/desktop",
20 ),
21 {
22 "@clerk/backend": "3.18.1",
23 "react-dom": "19.2.0",
24 "@opencode/protocol>effect": "4.0.0-rc.115",
25 "dbus-next>usocket": "-",
26 lodash: "4.17.21",
27 },
28 );
29 });
30
31 it("fails on a catalog entry that does not exist", () => {
32 assert.throws(
33 () => resolveCatalogDependencies({ "a>missing": "catalog:" }, catalog, "apps/desktop"),
34 /Expected key 'missing' in root workspace catalog/,
35 );
36 });
37
38 it("resolves version-qualified overrides without changing their selectors", () => {
39 assert.deepStrictEqual(
40 resolveCatalogDependencies(
41 {
42 "undici@^8": "catalog:",
43 "ws@^8": "catalog:",
44 "@clerk/backend@^3": "catalog:",
45 "@scope/parent@^1>undici@^8": "catalog:",
46 "parent@^1>@clerk/backend@^3": "catalog:",
47 },
48 { ...catalog, undici: "8.11.2", ws: "8.21.0" },
49 "apps/desktop",
50 ),
51 {
52 "undici@^8": "8.11.2",
53 "ws@^8": "8.21.0",
54 "@clerk/backend@^3": "3.18.1",
55 "@scope/parent@^1>undici@^8": "8.11.2",
56 "parent@^1>@clerk/backend@^3": "3.18.1",
57 },
58 );
59 });
60});