refactor(api): extract timeline allocation update support
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildTimelineAllocationEntryUpdate,
|
||||
buildTimelineAllocationMetadata,
|
||||
} from "../router/timeline-allocation-update-support.js";
|
||||
|
||||
describe("timeline allocation update support", () => {
|
||||
it("preserves existing metadata while updating includeSaturday", () => {
|
||||
const result = buildTimelineAllocationMetadata({
|
||||
existingMetadata: {
|
||||
recurrence: { frequency: "weekly", interval: 2 },
|
||||
includeSaturday: false,
|
||||
},
|
||||
includeSaturday: true,
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
metadata: {
|
||||
recurrence: { frequency: "weekly", interval: 2 },
|
||||
includeSaturday: true,
|
||||
},
|
||||
includeSaturday: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("builds shared update payloads for demand and assignment changes", () => {
|
||||
expect(
|
||||
buildTimelineAllocationEntryUpdate({
|
||||
hoursPerDay: 7.5,
|
||||
startDate: new Date("2026-04-01T00:00:00.000Z"),
|
||||
endDate: new Date("2026-04-10T00:00:00.000Z"),
|
||||
metadata: { includeSaturday: true },
|
||||
dailyCostCents: 48000,
|
||||
role: "Architect",
|
||||
}),
|
||||
).toEqual({
|
||||
demandRequirementUpdate: {
|
||||
hoursPerDay: 7.5,
|
||||
startDate: new Date("2026-04-01T00:00:00.000Z"),
|
||||
endDate: new Date("2026-04-10T00:00:00.000Z"),
|
||||
metadata: { includeSaturday: true },
|
||||
role: "Architect",
|
||||
},
|
||||
assignmentUpdate: {
|
||||
hoursPerDay: 7.5,
|
||||
startDate: new Date("2026-04-01T00:00:00.000Z"),
|
||||
endDate: new Date("2026-04-10T00:00:00.000Z"),
|
||||
dailyCostCents: 48000,
|
||||
metadata: { includeSaturday: true },
|
||||
role: "Architect",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user