import{newE2EPage}from"@stencil/core/testing";describe("sc-phone-input",(()=>{let t,e,a,i;const n="sc-phone-input";beforeEach((async()=>{t=await newE2EPage(),await t.setContent(`<${n}></${n}>`),e=await t.find(`${n}`),a=await t.find(`${n} >>> .input`),i=await t.find(`${n} >>> .input__control`),i.focus=jest.fn(),i.blur=jest.fn()})),it("renders",(async()=>{expect(e).toHaveClass("hydrated")})),it("Has sizes",(async()=>{a=await t.find(`${n} >>> .input`),expect(a).toHaveClass("input--medium"),await t.$eval(n,(t=>{t.size="small"})),await t.waitForChanges(),a=await t.find(`${n} >>> .input`),expect(a).toHaveClass("input--small"),await t.$eval(n,(t=>{t.size="large"})),await t.waitForChanges(),a=await t.find(`${n} >>> .input`),expect(a).toHaveClass("input--large")})),it("Can be focused and blurred",(async()=>{i=await t.find(`${n} >>> .input__control`);const o=await t.spyOnEvent("scBlur"),l=await t.spyOnEvent("scFocus");expect(a).not.toHaveClass("input--focused"),await i.click(),await t.waitForChanges(),a=await t.find(`${n} >>> .input`),expect(a).toHaveClass("input--focused"),expect(l).toHaveReceivedEvent(),await e.callMethod("triggerBlur"),await t.waitForChanges(),a=await t.find(`${n} >>> .input`),expect(a).not.toHaveClass("input--focused"),expect(o).toHaveReceivedEvent(),await e.callMethod("triggerFocus"),await t.waitForChanges(),a=await t.find(`${n} >>> .input`),expect(a).toHaveClass("input--focused"),expect(l).toHaveReceivedEvent(),await t.$eval(n,(t=>{t.hasFocus=!1})),await t.waitForChanges(),a=await t.find(`${n} >>> .input`),expect(a).not.toHaveClass("input--focused"),expect(o).toHaveReceivedEvent(),await t.$eval(n,(t=>{t.hasFocus=!0})),await t.waitForChanges(),a=await t.find(`${n} >>> .input`),expect(a).toHaveClass("input--focused"),expect(l).toHaveReceivedEvent()})),it("Changes value",(async()=>{i=await t.find(`${n} >>> .input__control`);const a=await t.spyOnEvent("scChange");let o=await i.getProperty("value");expect(o).toBe(""),await i.press("8"),await t.waitForChanges(),await i.press("8"),await t.waitForChanges(),o=await i.getProperty("value"),expect(o).toBe("88"),await e.callMethod("triggerBlur"),await t.waitForChanges(),expect(a).toHaveReceivedEvent()})),it("Has a name",(async()=>{i=await t.find(`${n} >>> .input__control`);let e=await i.getAttribute("name");expect(e).toBe(null),await t.$eval(n,(t=>{t.name="Test Name"})),await t.waitForChanges(),i=await t.find(`${n} >>> .input__control`),expect(i).toHaveAttribute("name");const a=await i.getAttribute("name");expect(a).toBe("Test Name")})),it("Can be disabled",(async()=>{i=await t.find(`${n} >>> .input__control`);let e=await i.getAttribute("disabled");expect(e).toBe(null),await t.$eval(n,(t=>{t.disabled=!0})),await t.waitForChanges(),i=await t.find(`${n} >>> .input__control`),expect(i).toHaveAttribute("disabled")})),it("Can be readonly",(async()=>{i=await t.find(`${n} >>> .input__control`);let e=await i.getAttribute("readonly");expect(e).toBe(null),await t.$eval(n,(t=>{t.readonly=!0})),await t.waitForChanges(),i=await t.find(`${n} >>> .input__control`),expect(i).toHaveAttribute("readonly")})),it("Can be required",(async()=>{i=await t.find(`${n} >>> .input__control`);let e=await i.getAttribute("required");expect(e).toBe(null),await t.$eval(n,(t=>{t.required=!0})),await t.waitForChanges(),i=await t.find(`${n} >>> .input__control`),expect(i).toHaveAttribute("required")})),it("Has a placeholder",(async()=>{i=await t.find(`${n} >>> .input__control`);let e=await i.getAttribute("placeholder");expect(e).toBe(null),await t.$eval(n,(t=>{t.placeholder="Test placeholder"})),await t.waitForChanges(),i=await t.find(`${n} >>> .input__control`),expect(i).toHaveAttribute("placeholder");const a=await i.getAttribute("placeholder");expect(a).toBe("Test placeholder")})),it("Can set min and max length",(async()=>{i=await t.find(`${n} >>> .input__control`);let e=await i.getAttribute("minlength"),a=await i.getAttribute("maxlength");expect(e).toBe(null),expect(a).toBe(null),await t.$eval(n,(t=>{t.minlength=10,t.maxlength=20})),await t.waitForChanges(),i=await t.find(`${n} >>> .input__control`),expect(i).toHaveAttribute("minlength"),expect(i).toHaveAttribute("maxlength");const o=await i.getAttribute("minlength"),l=await i.getAttribute("maxlength");expect(o).toBe("10"),expect(l).toBe("20")})),it("Can set min and max and step",(async()=>{i=await t.find(`${n} >>> .input__control`);let e=await i.getAttribute("min"),a=await i.getAttribute("max"),o=await i.getAttribute("step");expect(e).toBe(null),expect(a).toBe(null),expect(o).toBe(null),await t.$eval(n,(t=>{t.min=10,t.max=20,t.step=2})),await t.waitForChanges(),i=await t.find(`${n} >>> .input__control`),expect(i).toHaveAttribute("min"),expect(i).toHaveAttribute("max");const l=await i.getAttribute("min"),c=await i.getAttribute("max"),s=await i.getAttribute("step");expect(l).toBe("10"),expect(c).toBe("20"),expect(s).toBe("2")}))}));