import{newSpecPage}from"@stencil/core/testing";import{ScPayment}from"../sc-payment";import{dispose}from"../../../../../store/checkouts/index";import{dispose as disposeSelectedProcessor}from"../../../../../store/selected-processor/index";import{state as checkoutState,dispose as disposeCheckout}from"../../../../../store/checkout/index";import{state as processorsState,dispose as disposeProcessors}from"../../../../../store/processors/index";beforeEach((()=>{dispose(),disposeSelectedProcessor(),disposeProcessors(),disposeCheckout()})),describe("sc-payment",(()=>{it("renders no processors & user does not have `manage_sc_shop_settings` capability",(async()=>{const e=await newSpecPage({components:[ScPayment],html:"<sc-payment></sc-payment>"});expect(e.root).toMatchSnapshot()})),it("renders no processors & user has `manage_sc_shop_settings` capability",(async()=>{global.window=Object.create(window),Object.defineProperty(window,"scData",{value:{user_permissions:{manage_sc_shop_settings:!0},admin_url:"https://test.com/"}});const e=await newSpecPage({components:[ScPayment],html:"<sc-payment></sc-payment>"});expect(e.root).toMatchSnapshot()})),it("renders stripe and paypal with no checkout",(async()=>{const e=await newSpecPage({components:[ScPayment],html:"<sc-payment></sc-payment>"});processorsState.processors=[{live_mode:!0,recurring_enabled:!0,processor_type:"stripe"},{live_mode:!0,recurring_enabled:!1,processor_type:"paypal"}],await e.waitForChanges(),expect(e.root).toMatchSnapshot()})),it("only renders processors with the right mode",(async()=>{const e=await newSpecPage({components:[ScPayment],html:"<sc-payment></sc-payment>"});processorsState.processors=[{live_mode:!0,recurring_enabled:!0,processor_type:"stripe"},{live_mode:!1,recurring_enabled:!1,processor_type:"paypal"}],checkoutState.formId=1,checkoutState.mode="test",checkoutState.checkout={live_mode:!1},await e.waitForChanges(),expect(e.root).toMatchSnapshot()})),it("does not render non-recurring if recurring is required",(async()=>{const e=await newSpecPage({components:[ScPayment],html:"<sc-payment></sc-payment>"});processorsState.processors=[{live_mode:!1,recurring_enabled:!0,processor_type:"stripe"},{live_mode:!1,recurring_enabled:!1,processor_type:"paypal"}],checkoutState.formId=1,checkoutState.mode="test",checkoutState.checkout={live_mode:!1,reusable_payment_method_required:!0},await e.waitForChanges(),expect(e.root).toMatchSnapshot()})),it("only renders only mollie component if mollie is active",(async()=>{const e=await newSpecPage({components:[ScPayment],html:"<sc-payment></sc-payment>"});processorsState.processors=[{id:"mollieid",live_mode:!0,recurring_enabled:!0,processor_type:"mollie"},{live_mode:!0,recurring_enabled:!0,processor_type:"stripe"},{live_mode:!0,recurring_enabled:!1,processor_type:"paypal"}],checkoutState.formId=1,checkoutState.mode="live",checkoutState.checkout={live_mode:!0},await e.waitForChanges(),expect(e.root).toMatchSnapshot()})),it("renders mock processor with stripe",(async()=>{const e=await newSpecPage({components:[ScPayment],html:"<sc-payment></sc-payment>"});processorsState.processors=[{id:"stripeid",live_mode:!1,recurring_enabled:!0,processor_type:"stripe"},{id:"mockid",live_mode:!1,recurring_enabled:!0,processor_type:"mock"}],checkoutState.formId=1,checkoutState.mode="test",checkoutState.checkout={live_mode:!1},await e.waitForChanges(),expect(e.root).toMatchSnapshot()}))}));