summaryrefslogtreecommitdiffhomepage
path: root/packages/kernel/src/host/dag.test.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-27 01:09:39 +0900
committerAdam Malczewski <[email protected]>2026-06-27 01:09:39 +0900
commit61e45e60d699ed1ca46f94a8f181c92a940317c6 (patch)
tree2892d9773c5a8e367e1e58cdb1e88d9c6ad3fe6d /packages/kernel/src/host/dag.test.ts
parent63c7e64532e85e0bbdd6d9ac6825d8f86be98e7a (diff)
parent727c98c9dae516a2070eb950410314380a20c974 (diff)
downloaddispatch-61e45e60d699ed1ca46f94a8f181c92a940317c6.tar.gz
dispatch-61e45e60d699ed1ca46f94a8f181c92a940317c6.zip
Merge branch 'feature/indent-change' into dev
Diffstat (limited to 'packages/kernel/src/host/dag.test.ts')
-rw-r--r--packages/kernel/src/host/dag.test.ts196
1 files changed, 98 insertions, 98 deletions
diff --git a/packages/kernel/src/host/dag.test.ts b/packages/kernel/src/host/dag.test.ts
index 1a0431f..352965c 100644
--- a/packages/kernel/src/host/dag.test.ts
+++ b/packages/kernel/src/host/dag.test.ts
@@ -3,105 +3,105 @@ import type { Manifest } from "../contracts/extension.js";
import { resolveActivationOrder } from "./dag.js";
function manifest(id: string, deps?: readonly string[]): Manifest {
- const base: Manifest = {
- id,
- name: id,
- version: "1.0.0",
- apiVersion: "^0.1.0",
- trust: "bundled",
- };
- if (deps !== undefined) {
- return { ...base, dependsOn: deps };
- }
- return base;
+ const base: Manifest = {
+ id,
+ name: id,
+ version: "1.0.0",
+ apiVersion: "^0.1.0",
+ trust: "bundled",
+ };
+ if (deps !== undefined) {
+ return { ...base, dependsOn: deps };
+ }
+ return base;
}
describe("resolveActivationOrder", () => {
- it("returns empty array for no extensions", () => {
- expect(resolveActivationOrder([])).toEqual([]);
- });
-
- it("returns a single extension with no deps", () => {
- const result = resolveActivationOrder([manifest("a")]);
- expect(result.map((m) => m.id)).toEqual(["a"]);
- });
-
- it("orders a linear chain (A → B → C)", () => {
- const a = manifest("a");
- const b = manifest("b", ["a"]);
- const c = manifest("c", ["b"]);
-
- const result = resolveActivationOrder([c, b, a]);
- const ids = result.map((m) => m.id);
-
- expect(ids.indexOf("a")).toBeLessThan(ids.indexOf("b"));
- expect(ids.indexOf("b")).toBeLessThan(ids.indexOf("c"));
- });
-
- it("orders a diamond (A → B, A → C, B → D, C → D)", () => {
- const a = manifest("a");
- const b = manifest("b", ["a"]);
- const c = manifest("c", ["a"]);
- const d = manifest("d", ["b", "c"]);
-
- const result = resolveActivationOrder([d, c, b, a]);
- const ids = result.map((m) => m.id);
-
- expect(ids.indexOf("a")).toBeLessThan(ids.indexOf("b"));
- expect(ids.indexOf("a")).toBeLessThan(ids.indexOf("c"));
- expect(ids.indexOf("b")).toBeLessThan(ids.indexOf("d"));
- expect(ids.indexOf("c")).toBeLessThan(ids.indexOf("d"));
- });
-
- it("handles independent sets (no deps between them)", () => {
- const a = manifest("a");
- const b = manifest("b");
- const c = manifest("c");
-
- const result = resolveActivationOrder([a, b, c]);
- expect(result).toHaveLength(3);
- expect(result.map((m) => m.id).sort()).toEqual(["a", "b", "c"]);
- });
-
- it("throws on a cycle (A → B → A)", () => {
- const a = manifest("a", ["b"]);
- const b = manifest("b", ["a"]);
-
- expect(() => resolveActivationOrder([a, b])).toThrow(/cycle/i);
- });
-
- it("throws on a larger cycle (A → B → C → A)", () => {
- const a = manifest("a", ["c"]);
- const b = manifest("b", ["a"]);
- const c = manifest("c", ["b"]);
-
- expect(() => resolveActivationOrder([a, b, c])).toThrow(/cycle/i);
- });
-
- it("throws on a missing dependency", () => {
- const a = manifest("a", ["nonexistent"]);
-
- expect(() => resolveActivationOrder([a])).toThrow(/not available/);
- });
-
- it("throws on duplicate extension ids", () => {
- const a1 = manifest("a");
- const a2 = manifest("a");
-
- expect(() => resolveActivationOrder([a1, a2])).toThrow(/duplicate/i);
- });
-
- it("handles mixed independent and dependent extensions", () => {
- const a = manifest("a");
- const b = manifest("b", ["a"]);
- const c = manifest("c");
- const d = manifest("d", ["c"]);
-
- const result = resolveActivationOrder([a, b, c, d]);
- const ids = result.map((m) => m.id);
-
- expect(ids.indexOf("a")).toBeLessThan(ids.indexOf("b"));
- expect(ids.indexOf("c")).toBeLessThan(ids.indexOf("d"));
- expect(result).toHaveLength(4);
- });
+ it("returns empty array for no extensions", () => {
+ expect(resolveActivationOrder([])).toEqual([]);
+ });
+
+ it("returns a single extension with no deps", () => {
+ const result = resolveActivationOrder([manifest("a")]);
+ expect(result.map((m) => m.id)).toEqual(["a"]);
+ });
+
+ it("orders a linear chain (A → B → C)", () => {
+ const a = manifest("a");
+ const b = manifest("b", ["a"]);
+ const c = manifest("c", ["b"]);
+
+ const result = resolveActivationOrder([c, b, a]);
+ const ids = result.map((m) => m.id);
+
+ expect(ids.indexOf("a")).toBeLessThan(ids.indexOf("b"));
+ expect(ids.indexOf("b")).toBeLessThan(ids.indexOf("c"));
+ });
+
+ it("orders a diamond (A → B, A → C, B → D, C → D)", () => {
+ const a = manifest("a");
+ const b = manifest("b", ["a"]);
+ const c = manifest("c", ["a"]);
+ const d = manifest("d", ["b", "c"]);
+
+ const result = resolveActivationOrder([d, c, b, a]);
+ const ids = result.map((m) => m.id);
+
+ expect(ids.indexOf("a")).toBeLessThan(ids.indexOf("b"));
+ expect(ids.indexOf("a")).toBeLessThan(ids.indexOf("c"));
+ expect(ids.indexOf("b")).toBeLessThan(ids.indexOf("d"));
+ expect(ids.indexOf("c")).toBeLessThan(ids.indexOf("d"));
+ });
+
+ it("handles independent sets (no deps between them)", () => {
+ const a = manifest("a");
+ const b = manifest("b");
+ const c = manifest("c");
+
+ const result = resolveActivationOrder([a, b, c]);
+ expect(result).toHaveLength(3);
+ expect(result.map((m) => m.id).sort()).toEqual(["a", "b", "c"]);
+ });
+
+ it("throws on a cycle (A → B → A)", () => {
+ const a = manifest("a", ["b"]);
+ const b = manifest("b", ["a"]);
+
+ expect(() => resolveActivationOrder([a, b])).toThrow(/cycle/i);
+ });
+
+ it("throws on a larger cycle (A → B → C → A)", () => {
+ const a = manifest("a", ["c"]);
+ const b = manifest("b", ["a"]);
+ const c = manifest("c", ["b"]);
+
+ expect(() => resolveActivationOrder([a, b, c])).toThrow(/cycle/i);
+ });
+
+ it("throws on a missing dependency", () => {
+ const a = manifest("a", ["nonexistent"]);
+
+ expect(() => resolveActivationOrder([a])).toThrow(/not available/);
+ });
+
+ it("throws on duplicate extension ids", () => {
+ const a1 = manifest("a");
+ const a2 = manifest("a");
+
+ expect(() => resolveActivationOrder([a1, a2])).toThrow(/duplicate/i);
+ });
+
+ it("handles mixed independent and dependent extensions", () => {
+ const a = manifest("a");
+ const b = manifest("b", ["a"]);
+ const c = manifest("c");
+ const d = manifest("d", ["c"]);
+
+ const result = resolveActivationOrder([a, b, c, d]);
+ const ids = result.map((m) => m.id);
+
+ expect(ids.indexOf("a")).toBeLessThan(ids.indexOf("b"));
+ expect(ids.indexOf("c")).toBeLessThan(ids.indexOf("d"));
+ expect(result).toHaveLength(4);
+ });
});