feat(builder): add dynamic blocks email and dnd packages
Quality / quality (ubuntu-latest) (push) Failing after 11m26s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
Clintchiz committed 2026-09-03 14:00:41 +05:30
1 parent 06433e4ac4
commit 0bd2a6860d
37 files changed
+3060 -1

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
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));
});