Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2import { threadDragAction, threadOrderAfterMove } from "./threadOrder";
3import { threadDragGapOffset } from "./threadDragGap";
4
5describe("live thread insertion gap", () => {
6 const offsets = [0, 48, 120, 168, 240];
7 const shifts = (source: number, insertion: number) =>
8 offsets.map((offset) => threadDragGapOffset(offset, source, 72, insertion));
9
10 it("moves the Active header and intervening rows up when unpinning", () => {
11 expect(shifts(48, 312)).toEqual([0, 0, -72, -72, -72]);
12 });
13 it("opens a full gap below the Pinned header when pinning", () => {
14 expect(shifts(240, 48)).toEqual([0, 72, 72, 72, 0]);
15 });
16 it("leaves the source gap in place for cancellation or its current destination", () => {
17 expect(shifts(168, 168)).toEqual([0, 0, 0, 0, 0]);
18 expect(shifts(168, 240)).toEqual([0, 0, 0, 0, 0]);
19 });
20 it("moves only crossed rows for an adjacent reorder", () => {
21 expect(shifts(168, 312)).toEqual([0, 0, 0, 0, -72]);
22 expect(shifts(240, 168)).toEqual([0, 0, 0, 72, 0]);
23 });
24});
25
26describe("drag action labels", () => {
27 it("names the action for each destination instead of its section", () => {
28 expect(threadDragAction("active", "pinned")).toBe("Pin");
29 expect(threadDragAction("pinned", "active")).toBe("Unpin");
30 expect(threadDragAction("settled", "active")).toBe("Unsettle");
31 expect(threadDragAction("snoozed", "active")).toBe("Unsnooze");
32 expect(threadDragAction("active", "settled")).toBe("Settle");
33 expect(threadDragAction("pinned", "settled")).toBe("Settle");
34 expect(threadDragAction("active", "active")).toBe("Reorder");
35 });
36 it("does not offer a parked-section reorder or snooze without a wake time", () => {
37 expect(threadDragAction("settled", "settled")).toBeNull();
38 expect(threadDragAction("active", "snoozed")).toBeNull();
39 expect(
40 threadOrderAfterMove(["a", "b"], "a", {
41 section: "settled",
42 targetId: null,
43 placement: "before",
44 }),
45 ).toBeNull();
46 });
47});