|
| 1 | +import UseDisclosureDrawer from "../examples/use-disclosure-drawer.vue" |
| 2 | +import UseDisclosureProps from "../examples/use-disclosure-props.vue" |
| 3 | +import UseDisclosureToggle from "../examples/use-disclosure-toggle.vue" |
| 4 | + |
| 5 | +describe("useDisclosure with button/disclosure props", () => { |
| 6 | + it("is accessbile", () => { |
| 7 | + cy.mount(UseDisclosureProps).checkA11y() |
| 8 | + }) |
| 9 | + |
| 10 | + it("renders the button props correctly", () => { |
| 11 | + cy.mount(UseDisclosureProps) |
| 12 | + |
| 13 | + const button = cy.get("button") |
| 14 | + |
| 15 | + button |
| 16 | + .should("have.attr", "aria-expanded", "false") |
| 17 | + .and("have.attr", "aria-controls", "disclosure-2") |
| 18 | + }) |
| 19 | + |
| 20 | + it("toggles the disclosure", () => { |
| 21 | + cy.mount(UseDisclosureProps) |
| 22 | + |
| 23 | + cy.get("button").should("have.attr", "aria-expanded", "false") |
| 24 | + cy.get("#disclosure-3").should("be.hidden") |
| 25 | + |
| 26 | + cy.get("button") |
| 27 | + .invoke("click") |
| 28 | + .should("have.attr", "aria-expanded", "true") |
| 29 | + |
| 30 | + cy.get("#disclosure-3").should("not.be.hidden") |
| 31 | + |
| 32 | + cy.get("button") |
| 33 | + .invoke("click") |
| 34 | + .should("have.attr", "aria-expanded", "false") |
| 35 | + cy.get("#disclosure-3").should("be.hidden") |
| 36 | + }) |
| 37 | +}) |
| 38 | + |
| 39 | +describe("useDisclosure with onToggle", () => { |
| 40 | + it("toggles the text", () => { |
| 41 | + cy.mount(UseDisclosureToggle) |
| 42 | + |
| 43 | + cy.contains("div", "Toggled On with onToggle!").should("be.hidden") |
| 44 | + |
| 45 | + cy.get("button").contains("This is a button").invoke("click") |
| 46 | + |
| 47 | + cy.contains("div", "Toggled On with onToggle!").should("not.be.hidden") |
| 48 | + }) |
| 49 | +}) |
| 50 | + |
| 51 | +describe("useDisclosure with drawer", () => { |
| 52 | + it("toggles drawer", () => { |
| 53 | + cy.mount(UseDisclosureDrawer) |
| 54 | + |
| 55 | + cy.get(".chakra-modal__content-container").should("not.exist") |
| 56 | + |
| 57 | + cy.contains("button", "Open Drawer").invoke("click") |
| 58 | + |
| 59 | + cy.get(".chakra-modal__content-container") |
| 60 | + .should("exist") |
| 61 | + .get(".chakra-modal__close-button") |
| 62 | + .invoke("click") |
| 63 | + |
| 64 | + cy.get(".chakra-modal__content-container").should("not.exist") |
| 65 | + }) |
| 66 | +}) |
0 commit comments