import{hasAnyRuleGroupPassed,compareNumberValues,compareObjectValues,hasRulesPassed,getCartPriceIds}from"../conditional-functions";describe("Conditional form logic",(()=>{describe("hasAnyRuleGroupPassed",(()=>{it("Test Rule groups",(()=>{let e=hasAnyRuleGroupPassed([{group_id:"asdf",rules:[{condition:"total",operator:"==",value:"10000"}]}],{checkout:{total_amount:1e4},processor:"stripe"});expect(e).toBe(!0)}))})),describe("hasRulesPassed",(()=>{it("Order total and processor",(()=>{expect(hasRulesPassed([{condition:"total",operator:"==",value:"10000"},{condition:"processors",operator:"any",value:["test_processor_id"]}],{checkout:{total_amount:1e4},processor:"test_processor_id"})).toBe(!0),expect(hasRulesPassed([{condition:"total",operator:"==",value:"10000"},{condition:"processors",operator:"any",value:["test_processor_id"]}],{checkout:{total_amount:10001},processor:"test_processor_id"})).toBe(!1),expect(hasRulesPassed([{condition:"total",operator:"==",value:"10000"},{condition:"processors",operator:"any",value:["test_processor_id"]}],{checkout:{total_amount:1e4},processor:"test_processor_id1"})).toBe(!1)})),it("Prices condition",(()=>{const e={line_items:{data:[{price:{id:"price_abc"}}]}};expect(hasRulesPassed([{condition:"prices",operator:"any",value:["price_abc"]}],{checkout:e,processor:"stripe"})).toBe(!0),expect(hasRulesPassed([{condition:"prices",operator:"none",value:["price_xyz"]}],{checkout:e,processor:"stripe"})).toBe(!0),expect(hasRulesPassed([{condition:"prices",operator:"all",value:["price_abc","price_xyz"]}],{checkout:e,processor:"stripe"})).toBe(!1)}))})),describe("getCartPriceIds",(()=>{it("extracts price ids from line items",(()=>{expect(getCartPriceIds({line_items:{data:[{price:{id:"price_abc"}},{price:{id:"price_def"}}]}})).toEqual(["price_abc","price_def"])})),it("filters out line items with missing price ids (e.g. ad_hoc)",(()=>{expect(getCartPriceIds({line_items:{data:[{price:{id:"price_abc"}},{price:{id:null}}]}})).toEqual(["price_abc"])})),it("returns empty array when line_items is missing",(()=>{expect(getCartPriceIds({})).toEqual([])}))})),describe("compareNumberValues",(()=>{it("Order total is less than 100",(()=>{let e=compareNumberValues(90,parseFloat("100"),"<");expect(e).toBe(!0)})),it("Order total is greater than 100",(()=>{let e=compareNumberValues(120,100,">");expect(e).toBe(!0)})),it("Order total is equal to 100",(()=>{let e=compareNumberValues(100,100,"==");expect(e).toBe(!0)}))})),describe("compareObjectValues",(()=>{const e=["c08275a8-4a1a-4e69-a488-e508f92e9dac","5aaf576f-6bcb-49cd-8c4c-f2ef264f03d8"];describe("Products",(()=>{it("Cart contains any of the product",(()=>{expect(compareObjectValues(["c08275a8-4a1a-4e69-a488-e508f92e9dac"],e,"any")).toBe(!0)})),it("Cart contains all of the product",(()=>{expect(compareObjectValues(["c08275a8-4a1a-4e69-a488-e508f92e9dac","5aaf576f-6bcb-49cd-8c4c-f2ef264f03d8"],e,"all")).toBe(!0)})),it("Cart contains none of the product",(()=>{expect(compareObjectValues(["c08275a8-4a1a-4e69-a488-e508f92e9daq"],e,"none")).toBe(!0)}))})),describe("Coupons",(()=>{const e=["c638aa78-5b51-4d4f-a96a-bf1a462db6c5","93363978-1ba8-4d87-9108-68d90825b386"];it("Cart contains any of the coupon",(()=>{expect(compareObjectValues(["c638aa78-5b51-4d4f-a96a-bf1a462db6c5"],e,"any")).toBe(!0)})),it("Cart contains all of the coupons",(()=>{expect(compareObjectValues(["c638aa78-5b51-4d4f-a96a-bf1a462db6c5","93363978-1ba8-4d87-9108-68d90825b386"],e,"all")).toBe(!0)})),it("Cart contains none of the coupon",(()=>{expect(compareObjectValues(["c08275a8-4a1a-4e69-a488-e508f92e9daq"],e,"none")).toBe(!0)})),it("Cart - coupon exists",(()=>{expect(compareObjectValues(["c08275a8-4a1a-4e69-a488-e508f92e9daq"],e,"exist")).toBe(!0),expect(compareObjectValues([],e,"exist")).toBe(!1)})),it("Cart - coupon not exist",(()=>{expect(compareObjectValues(["asdf"],e,"not_exist")).toBe(!1),expect(compareObjectValues([],e,"not_exist")).toBe(!0)}))})),describe("Shipping & Billing Country",(()=>{const e=["IN"];it("Cart contains any of the country",(()=>{let t=compareObjectValues(["IN"],e,"any");expect(t).toBe(!0)})),it("Cart contains none of the country",(()=>{let t=compareObjectValues(["US"],e,"none");expect(t).toBe(!0)}))})),describe("Payment Processor",(()=>{const e=["stripe"];it("Selected payment for cart - any",(()=>{expect(compareObjectValues(["stripe"],e,"any")).toBe(!0)})),it("Selected payment for cart - none",(()=>{expect(compareObjectValues(["paypal"],e,"none")).toBe(!0)}))}))}))}));