import { describe, expect, test } from "bun:test"; import { deepestValidTarget, reorderGroups, visualIndex } from "../src/index.ts"; describe("dnd pure behavior", () => { test("moves across groups without mutation", () => { const input = new Map([ ["a", ["1", "2"]], ["b", ["3"]], ]); const result = reorderGroups(input, { ids: ["2"], from: [{ group: "a", index: 1 }], to: { group: "b", index: 0 }, }); expect(result.get("a")).toEqual(["1"]); expect(result.get("b")).toEqual(["2", "3"]); expect(input.get("a")).toEqual(["1", "2"]); }); test("mirrors horizontal RTL index", () => expect(visualIndex(0, 4, "horizontal", "rtl")).toBe(3)); test("selects deepest valid target", () => expect( deepestValidTarget( [ { depth: 1, location: { group: "a", index: 0 } }, { depth: 3, location: { group: "b", index: 0 } }, ], (location) => location.group === "b", )?.depth, ).toBe(3)); });