45 lines
1.9 KiB
TypeScript
45 lines
1.9 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { buildInitialState, getScenario } from "../src/domain/scenarios.ts";
|
|
import { nextState, resolve } from "../src/domain/transition.ts";
|
|
import { canonical, cloneState, canonicalEqual, gateIndex } from "../src/domain/core.ts";
|
|
|
|
describe("smoke", () => {
|
|
it("builds and runs scenario 1 initial rotation without throwing", () => {
|
|
const s = buildInitialState(getScenario("s1-heat"), "campaign");
|
|
const before = cloneState(s);
|
|
const next = nextState(s, { ring: "outer", dir: "cw" });
|
|
// input immutability
|
|
expect(canonicalEqual(before, s)).toBe(true);
|
|
// turn advanced
|
|
expect(next.turn).toBe(1);
|
|
// outer ring direction updated
|
|
expect(next.rings.outer.direction).toBe("cw");
|
|
// action logged
|
|
expect(next.actionLog).toHaveLength(1);
|
|
});
|
|
|
|
it("cw rotation moves payload at i to i+1", () => {
|
|
const s = buildInitialState(getScenario("s1-heat"), "campaign");
|
|
// O0 has producer 2, nutrient 3; rotate outer cw -> payload moves to O1, then grows to 3
|
|
const next = nextState(s, { ring: "outer", dir: "cw" });
|
|
expect(next.rings.outer.tiles[1].producer).toBe(3); // 2 from rotation + 1 growth
|
|
expect(next.rings.outer.tiles[0].producer).toBe(0);
|
|
});
|
|
|
|
it("resolve returns deterministic events", () => {
|
|
const s = buildInitialState(getScenario("s1-heat"), "campaign");
|
|
const a = nextState(s, { ring: "inner", dir: "cw" });
|
|
const b = nextState(s, { ring: "inner", dir: "cw" });
|
|
expect(canonical(a)).toBe(canonical(b));
|
|
const { events } = resolve(s, { ring: "inner", dir: "cw" });
|
|
expect(events.some((e) => e.phase === "rotate")).toBe(true);
|
|
expect(events.some((e) => e.phase === "outcome")).toBe(true);
|
|
});
|
|
|
|
it("gate index derivation", () => {
|
|
expect(gateIndex("inner", 0)).toBe(0);
|
|
expect(gateIndex("middle", 1)).toBe(2);
|
|
expect(gateIndex("outer", 2)).toBe(6);
|
|
});
|
|
});
|