import { describe, expect, it } from "vitest"; import { emptySku, skuFromView, skuPart, type SkuDraft } from "./catalogSetup"; // add-sku-supplier: a SKU carries one optional supplier id end to end. describe("SKU supplier", () => { it("starts with no supplier", () => { expect(emptySku().supplierId).toBeNull(); }); it("loads the supplier id from the view, and null when absent", () => { const base = { id: 14, code: "BA-001", name: "Bodysuit", status: "Y" as const, variations: [] }; expect(skuFromView({ ...base, supplierId: 3 }).supplierId).toBe(3); expect(skuFromView(base).supplierId).toBeNull(); }); it("always sends the supplier id, null clearing it", () => { const draft: SkuDraft = { ...emptySku(), code: "BA-010", name: "Romper", supplierId: 3 }; expect(skuPart(draft)).toMatchObject({ supplierId: 3 }); expect(skuPart({ ...draft, supplierId: null })).toHaveProperty("supplierId", null); }); });