import { describe, expect, it } from "vitest"; import { hasCapacity, remainingCapacity } from "../../app/services/capacity.server"; describe("remainingCapacity", () => { it("subtracts consumed from capacity", () => { expect(remainingCapacity({ capacity: 10, consumed: 3 })).toBe(7); }); it("floors at 0 rather than going negative (overbooking never surfaces as negative capacity)", () => { expect(remainingCapacity({ capacity: 10, consumed: 15 })).toBe(0); }); it("treats zero consumed as full capacity", () => { expect(remainingCapacity({ capacity: 10, consumed: 0 })).toBe(10); }); }); describe("hasCapacity", () => { it("is true when remaining capacity is positive", () => { expect(hasCapacity({ capacity: 10, consumed: 9 })).toBe(true); }); it("is false when exactly full", () => { expect(hasCapacity({ capacity: 10, consumed: 10 })).toBe(false); }); it("is false when over capacity", () => { expect(hasCapacity({ capacity: 10, consumed: 11 })).toBe(false); }); });