diff --git a/src/lib/plant-hours-schema.test.ts b/src/lib/plant-hours-schema.test.ts index 31fc27e..18a2244 100644 --- a/src/lib/plant-hours-schema.test.ts +++ b/src/lib/plant-hours-schema.test.ts @@ -41,6 +41,17 @@ describe("computePlantHoursFields", () => { expect(computePlantHoursFields(validRow).value).toBe(5735); // 31 * 185 = 5735 exactly }); + it("rounds value to 2 decimal places", () => { + // 31.5 * 185.25 = 5835.375, rounds to 5835.38 + const r = computePlantHoursFields({ + ...validRow, + start_hours: 1200, + end_hours: 1231.5, + hours: 31.5, + cost_per_hour: 185.25, + }); + expect(r.value).toBe(5835.38); + }); it("flags over_budget when hours > hour_meter_budget", () => { expect(computePlantHoursFields(validRow).over_budget).toBe(false); expect( @@ -72,6 +83,15 @@ describe("validatePlantHoursRow", () => { expect(r.errors[0]).toMatch(/unknown_vehicle_qr/); }); + it("rejects when supplied vehicle's QR doesn't match row QR", () => { + const r = validatePlantHoursRow( + validRow, // vehicle_qr is "QR-A" + { ...baseVehicle, qr_code_id: "QR-Z" }, // vehicle is defined but QR doesn't match + new Set(), + ); + expect(r.errors[0]).toMatch(/unknown_vehicle_qr/); + }); + it("rejects end_date < start_date", () => { const r = validatePlantHoursRow( { ...validRow, end_date: "2026-08-23" },