FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
collection
/
components
/
ui
/
input
/
test
Edit File: sc-input.e2e.js
import{newE2EPage}from"@stencil/core/testing";describe("sc-input",(()=>{const t="sc-input";it("renders",(async()=>{const e=await newE2EPage();await e.setContent(`<${t}></${t}>`);const a=await e.find(`${t}`);expect(a).toHaveClass("hydrated")})),it("Has sizes",(async()=>{const e=await newE2EPage();await e.setContent(`<${t}></${t}>`);let a=await e.find(`${t} >>> .input`);expect(a).toHaveClass("input--medium"),await e.$eval(t,(t=>{t.size="small"})),await e.waitForChanges(),a=await e.find(`${t} >>> .input`),expect(a).toHaveClass("input--small"),await e.$eval(t,(t=>{t.size="large"})),await e.waitForChanges(),a=await e.find(`${t} >>> .input`),expect(a).toHaveClass("input--large")})),it("Can be focused and blurred",(async()=>{const e=await newE2EPage();await e.setContent(`<${t}></${t}>`);const a=await e.find(`${t}`);let i=await e.find(`${t} >>> .input`);const n=await e.spyOnEvent("scBlur"),o=await e.spyOnEvent("scFocus");expect(i).not.toHaveClass("input--focused");let w=await e.find(`${t} >>> .input__control`);await w.click(),await e.waitForChanges(),i=await e.find(`${t} >>> .input`),expect(i).toHaveClass("input--focused"),expect(o).toHaveReceivedEvent(),await a.callMethod("triggerBlur"),await e.waitForChanges(),i=await e.find(`${t} >>> .input`),expect(i).not.toHaveClass("input--focused"),expect(n).toHaveReceivedEvent(),await a.callMethod("triggerFocus"),await e.waitForChanges(),i=await e.find(`${t} >>> .input`),expect(i).toHaveClass("input--focused"),expect(o).toHaveReceivedEvent(),await e.$eval(t,(t=>{t.hasFocus=!1})),await e.waitForChanges(),i=await e.find(`${t} >>> .input`),expect(i).not.toHaveClass("input--focused"),expect(n).toHaveReceivedEvent()})),it("Changes value",(async()=>{const e=await newE2EPage();await e.setContent(`<${t}></${t}>`);const a=await e.find(`${t}`);let i=await e.find(`${t} >>> .input__control`);const n=await e.spyOnEvent("scChange");let o=await i.getProperty("value");expect(o).toBe(""),await i.press("8"),await e.waitForChanges(),await i.press("8"),await e.waitForChanges(),o=await i.getProperty("value"),expect(o).toBe("88"),await a.callMethod("triggerBlur"),await e.waitForChanges(),expect(n).toHaveReceivedEvent()})),it("Has a name",(async()=>{const e=await newE2EPage();await e.setContent(`<${t}></${t}>`);let a=await e.find(`${t} >>> .input__control`),i=await a.getAttribute("name");expect(i).toBe(null),await e.$eval(t,(t=>{t.name="Test Name"})),await e.waitForChanges(),a=await e.find(`${t} >>> .input__control`),expect(a).toHaveAttribute("name");const n=await a.getAttribute("name");expect(n).toBe("Test Name")})),it("Can be disabled",(async()=>{const e=await newE2EPage();await e.setContent(`<${t}></${t}>`);let a=await e.find(`${t} >>> .input__control`),i=await a.getAttribute("disabled");expect(i).toBe(null),await e.$eval(t,(t=>{t.disabled=!0})),await e.waitForChanges(),a=await e.find(`${t} >>> .input__control`),expect(a).toHaveAttribute("disabled")})),it("Can be readonly",(async()=>{const e=await newE2EPage();await e.setContent(`<${t}></${t}>`);let a=await e.find(`${t} >>> .input__control`),i=await a.getAttribute("readonly");expect(i).toBe(null),await e.$eval(t,(t=>{t.readonly=!0})),await e.waitForChanges(),a=await e.find(`${t} >>> .input__control`),expect(a).toHaveAttribute("readonly")})),it("Can be required",(async()=>{const e=await newE2EPage();await e.setContent(`<${t}></${t}>`);let a=await e.find(`${t} >>> .input__control`),i=await a.getAttribute("required");expect(i).toBe(null),await e.$eval(t,(t=>{t.required=!0})),await e.waitForChanges(),a=await e.find(`${t} >>> .input__control`),expect(a).toHaveAttribute("required")})),it("Has a placeholder",(async()=>{const e=await newE2EPage();await e.setContent(`<${t}></${t}>`);let a=await e.find(`${t} >>> .input__control`),i=await a.getAttribute("placeholder");expect(i).toBe(null),await e.$eval(t,(t=>{t.placeholder="Test placeholder"})),await e.waitForChanges(),a=await e.find(`${t} >>> .input__control`),expect(a).toHaveAttribute("placeholder");const n=await a.getAttribute("placeholder");expect(n).toBe("Test placeholder")})),it("Can set min and max length",(async()=>{const e=await newE2EPage();await e.setContent(`<${t}></${t}>`);let a=await e.find(`${t} >>> .input__control`),i=await a.getAttribute("minlength"),n=await a.getAttribute("maxlength");expect(i).toBe(null),expect(n).toBe(null),await e.$eval(t,(t=>{t.minlength=10,t.maxlength=20})),await e.waitForChanges(),a=await e.find(`${t} >>> .input__control`),expect(a).toHaveAttribute("minlength"),expect(a).toHaveAttribute("maxlength");const o=await a.getAttribute("minlength"),w=await a.getAttribute("maxlength");expect(o).toBe("10"),expect(w).toBe("20")})),it("Can set min and max and step",(async()=>{const e=await newE2EPage();await e.setContent(`<${t}></${t}>`);let a=await e.find(`${t} >>> .input__control`),i=await a.getAttribute("min"),n=await a.getAttribute("max"),o=await a.getAttribute("step");expect(i).toBe(null),expect(n).toBe(null),expect(o).toBe(null),await e.$eval(t,(t=>{t.min=10,t.max=20,t.step=2})),await e.waitForChanges(),a=await e.find(`${t} >>> .input__control`),expect(a).toHaveAttribute("min"),expect(a).toHaveAttribute("max");const w=await a.getAttribute("min"),s=await a.getAttribute("max"),c=await a.getAttribute("step");expect(w).toBe("10"),expect(s).toBe("20"),expect(c).toBe("2")}))}));
Save
Back