FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
collection
/
components
/
ui
/
choice
/
test
Edit File: sc-choice.e2e.js
import{newE2EPage}from"@stencil/core/testing";describe("sc-choice",(()=>{let e,t,a,i;const c="sc-choice";beforeEach((async()=>{e=await newE2EPage(),await e.setContent(`<${c}></${c}>`),t=await e.find(`${c}`),a=await e.find(`${c} >>> .choice`),i=await e.find(`${c} >>> input`)})),it("renders",(async()=>{const e=await newE2EPage();await e.setContent("<sc-choice></sc-choice>");const t=await e.find(c);expect(t).toHaveClass("hydrated")})),it("Should be clickable",(async()=>{a=await e.find(`${c} >>> .choice`),i=await e.find(`${c} >>> input`);const t=await e.spyOnEvent("scBlur"),o=await e.spyOnEvent("scFocus");expect(a).toHaveClass("choice"),expect(a).not.toHaveClasses(["choice--checked","choice--focused"]),await i.click(),await e.waitForChanges(),a=await e.find(`${c} >>> .choice`),expect(a).toHaveClass("choice"),expect(a).toHaveClasses(["choice--checked","choice--focused"]),expect(o).toHaveReceivedEvent(),await e.$eval(c,(e=>e.blur())),await e.waitForChanges(),a=await e.find(`${c} >>> .choice`),expect(a).not.toHaveClass("choice--focused"),expect(t).toHaveReceivedEvent()})),it("Can be disabled",(async()=>{i=await e.find(`${c} >>> input`),expect(i).not.toHaveAttribute("disabled"),t.setProperty("disabled",!0),await e.waitForChanges(),a=await e.find(`${c} >>> .choice`),i=await e.find(`${c} >>> input`),expect(a).toHaveClasses(["choice","choice--disabled"]),expect(i).toHaveAttribute("disabled")})),it("Can be radio or checkbox",(async()=>{i=await e.find(`${c} >>> input`),expect(i).toEqualAttribute("type","radio"),t.setProperty("type","checkbox"),await e.waitForChanges(),i=await e.find(`${c} >>> input`),expect(i).toEqualAttribute("type","checkbox")}))}));
Save
Back