refactor(web): extract range selection bootstrap
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { finalizeRangeSelection, updateRangeSelectionDraft } from "./timelineRangeSelection.js";
|
||||
import { createRangeSelectionState, finalizeRangeSelection, updateRangeSelectionDraft } from "./timelineRangeSelection.js";
|
||||
|
||||
type TestRangeState = {
|
||||
isSelecting: boolean;
|
||||
@@ -11,6 +11,23 @@ type TestRangeState = {
|
||||
};
|
||||
|
||||
describe("timelineRangeSelection", () => {
|
||||
it("creates a selection draft with currentDate anchored to the start date", () => {
|
||||
expect(
|
||||
createRangeSelectionState<TestRangeState>(
|
||||
"res-1",
|
||||
new Date("2025-01-15T12:00:00.000Z"),
|
||||
100,
|
||||
),
|
||||
).toEqual({
|
||||
isSelecting: true,
|
||||
resourceId: "res-1",
|
||||
startDate: new Date("2025-01-15T12:00:00.000Z"),
|
||||
currentDate: new Date("2025-01-15T12:00:00.000Z"),
|
||||
suggestedProjectId: null,
|
||||
startClientX: 100,
|
||||
});
|
||||
});
|
||||
|
||||
it("ignores updates when no full day boundary was crossed", () => {
|
||||
const state: TestRangeState = {
|
||||
isSelecting: true,
|
||||
|
||||
Reference in New Issue
Block a user