import{newSpecPage}from"@stencil/core/testing";import{ScCustomerName}from"../sc-customer-name";import{dispose as disposeCheckout,state as checkoutState}from"../../../../../store/checkout/index";import{dispose as disposeUser,state as userState}from"../../../../../store/user/index";describe("sc-customer-name",(()=>{beforeEach((()=>{disposeCheckout(),disposeUser()}));const e=[{testLabel:"Customer and Checkout names provided",checkout:{name:"CheckoutFirst CheckoutLast",customer:{name:"CustomerFirst CustomerLast"}}},{testLabel:"Customer name provided",checkout:{customer:{name:"CustomerFirst CustomerLast"}}},{testLabel:"Checkout name provided",checkout:{name:"CheckoutFirst CheckoutLast"}}];function t(e){global.window=Object.create(window),Object.defineProperty(window,"location",{value:{search:e?new URLSearchParams("?full_name=UrlFirst UrlLast").toString():""},writable:!0})}describe.each(e)("Logged In",(e=>{it(`${e.testLabel} with URL Params`,(async()=>{t(!0),userState.loggedIn=!0,checkoutState.checkout=e.checkout;const o=await newSpecPage({components:[ScCustomerName],html:"<sc-customer-name></sc-customer-name>"});expect(o.root).toMatchSnapshot(),o.rootInstance.disconnectedCallback()})),it(`${e.testLabel} without URL Params`,(async()=>{t(!1),userState.loggedIn=!0,checkoutState.checkout=e.checkout;const o=await newSpecPage({components:[ScCustomerName],html:"<sc-customer-name></sc-customer-name>"});expect(o.root).toMatchSnapshot(),o.rootInstance.disconnectedCallback()}))})),describe.each(e)("Logged Out",(e=>{it(`${e.testLabel} with URL Params`,(async()=>{t(!0),userState.loggedIn=!1,checkoutState.checkout=e.checkout;const o=await newSpecPage({components:[ScCustomerName],html:"<sc-customer-name></sc-customer-name>"});expect(o.root).toMatchSnapshot(),o.rootInstance.disconnectedCallback()})),it(`${e.testLabel} without URL Params`,(async()=>{t(!1),userState.loggedIn=!1,checkoutState.checkout=e.checkout;const o=await newSpecPage({components:[ScCustomerName],html:"<sc-customer-name></sc-customer-name>"});expect(o.root).toMatchSnapshot(),o.rootInstance.disconnectedCallback()}))}))}));