feat(builder): add dynamic blocks email and dnd packages
This commit is contained in:
1 parent
06433e4ac4
commit
0bd2a6860d
37 files changed
+3060
-1
No files matched your search
@@ -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));
|
||||
});
|
||||
Reference in new issue
Block a user