import{isProductVariantOptionSoldOut}from"../utils";const makeProduct=(t={})=>({id:"prod_1",has_unlimited_stock:!1,available_stock:10,variants:{data:[]},...t}),makeVariant=(t={})=>({id:"var_1",option_1:"Small",option_2:null,option_3:null,has_unlimited_stock:!1,available_stock:5,...t});describe("isProductVariantOptionSoldOut",(()=>{it("returns false when variant has stock",(()=>{const t=makeProduct({variants:{data:[makeVariant({option_1:"Small",available_stock:5})]}});expect(isProductVariantOptionSoldOut(1,"Small",{},t)).toBe(!1)})),it("returns true when all matching variants have zero stock",(()=>{const t=makeProduct({variants:{data:[makeVariant({option_1:"Small",available_stock:0}),makeVariant({id:"var_2",option_1:"Small",available_stock:0})]}});expect(isProductVariantOptionSoldOut(1,"Small",{},t)).toBe(!0)})),it("returns false when no variants match the option",(()=>{const t=makeProduct({variants:{data:[makeVariant({option_1:"Large",available_stock:0})]}});expect(isProductVariantOptionSoldOut(1,"Small",{},t)).toBe(!1)})),it("returns false when variant has unlimited stock even with zero available",(()=>{const t=makeProduct({variants:{data:[makeVariant({option_1:"Small",has_unlimited_stock:!0,available_stock:0})]}});expect(isProductVariantOptionSoldOut(1,"Small",{},t)).toBe(!1)})),it("returns false when variant inherits unlimited from product",(()=>{const t=makeProduct({has_unlimited_stock:!0,variants:{data:[makeVariant({option_1:"Small",has_unlimited_stock:null,available_stock:0})]}});expect(isProductVariantOptionSoldOut(1,"Small",{},t)).toBe(!1)})),it("returns true when variant inherits tracked stock from product and is sold out",(()=>{const t=makeProduct({has_unlimited_stock:!1,variants:{data:[makeVariant({option_1:"Small",has_unlimited_stock:null,available_stock:0})]}});expect(isProductVariantOptionSoldOut(1,"Small",{},t)).toBe(!0)})),it("handles option 2 filtering correctly",(()=>{const t=makeProduct({variants:{data:[makeVariant({option_1:"Small",option_2:"Red",available_stock:0}),makeVariant({id:"var_2",option_1:"Small",option_2:"Blue",available_stock:5})]}});expect(isProductVariantOptionSoldOut(2,"Red",{option_1:"Small"},t)).toBe(!0),expect(isProductVariantOptionSoldOut(2,"Blue",{option_1:"Small"},t)).toBe(!1)})),it("handles option 3 filtering correctly",(()=>{const t=makeProduct({variants:{data:[makeVariant({option_1:"Small",option_2:"Red",option_3:"Cotton",available_stock:0}),makeVariant({id:"var_2",option_1:"Small",option_2:"Red",option_3:"Silk",available_stock:3})]}});expect(isProductVariantOptionSoldOut(3,"Cotton",{option_1:"Small",option_2:"Red"},t)).toBe(!0),expect(isProductVariantOptionSoldOut(3,"Silk",{option_1:"Small",option_2:"Red"},t)).toBe(!1)}))}));