import{getMaxStockQuantity}from"../quantity";const makeProduct=(t={})=>({id:"prod_1",has_unlimited_stock:!1,available_stock:10,purchase_limit:null,...t}),makeVariant=(t={})=>({id:"var_1",has_unlimited_stock:!1,available_stock:5,...t});describe("getMaxStockQuantity",(()=>{it("returns purchase_limit when set",(()=>{const t=makeProduct({purchase_limit:3});expect(getMaxStockQuantity(t)).toBe(3)})),it("returns null when product has unlimited stock",(()=>{const t=makeProduct({has_unlimited_stock:!0});expect(getMaxStockQuantity(t)).toBeNull()})),it("returns product available_stock when stock is tracked and no variant",(()=>{const t=makeProduct({available_stock:7});expect(getMaxStockQuantity(t)).toBe(7)})),it("returns null when variant has unlimited stock",(()=>{const t=makeProduct({has_unlimited_stock:!1}),a=makeVariant({has_unlimited_stock:!0});expect(getMaxStockQuantity(t,a)).toBeNull()})),it("returns variant available_stock when variant stock is tracked",(()=>{const t=makeProduct({has_unlimited_stock:!1,available_stock:10}),a=makeVariant({has_unlimited_stock:!1,available_stock:3});expect(getMaxStockQuantity(t,a)).toBe(3)})),it("returns null when variant inherits unlimited from product",(()=>{const t=makeProduct({has_unlimited_stock:!0}),a=makeVariant({has_unlimited_stock:null,available_stock:0});expect(getMaxStockQuantity(t,a)).toBeNull()})),it("returns variant stock when variant inherits tracked from product",(()=>{const t=makeProduct({has_unlimited_stock:!1,available_stock:10}),a=makeVariant({has_unlimited_stock:null,available_stock:2});expect(getMaxStockQuantity(t,a)).toBe(2)}))}));