import { describe, expect, it } from "vitest"; import type { VariantConstraint } from "../../src/domain"; import { removeKillerCagesAtCells, replaceOverlappingKillerCages, selectionTouchesKillerCage, } from "../../src/components/constraintEditing"; const constraints: VariantConstraint[] = [ { type: "killer-cage", cells: [0, 1], sum: 3 }, { type: "killer-cage", cells: [2, 3], sum: 7 }, { type: "thermo", cells: [0, 4] }, ]; describe("setter cage editing", () => { it("replaces every overlapping cage while preserving other rules", () => { expect( replaceOverlappingKillerCages(constraints, { type: "killer-cage", cells: [1, 2], sum: 5, }), ).toEqual([ { type: "thermo", cells: [0, 4] }, { type: "killer-cage", cells: [1, 2], sum: 5 }, ]); }); it("removes cages by any selected member cell", () => { expect(removeKillerCagesAtCells(constraints, [1])).toEqual([ { type: "killer-cage", cells: [2, 3], sum: 7 }, { type: "thermo", cells: [0, 4] }, ]); expect(selectionTouchesKillerCage(constraints, [1])).toBe(true); expect(selectionTouchesKillerCage(constraints, [4])).toBe(false); }); });