|
1 | | -import { Spinner } from "@salt-ds/lab"; |
| 1 | +import { Spinner } from "@salt-ds/core"; |
| 2 | +import { getContainerEl } from "cypress/react"; |
| 3 | +import ReactDOM from "react-dom"; |
2 | 4 |
|
3 | 5 | const ariaLabel = "Loading component"; |
4 | 6 |
|
@@ -33,31 +35,22 @@ describe("GIVEN an available announcer", () => { |
33 | 35 |
|
34 | 36 | // TODO fix unmount announcement |
35 | 37 | it.skip("THEN the announcer should be called when the component unmounts", () => { |
36 | | - cy.mount(<Spinner aria-label={ariaLabel} />).then(({ unmount }) => { |
37 | | - unmount().then(() => { |
38 | | - cy.get("body").should("announce", `finished ${ariaLabel}`); |
39 | | - }); |
40 | | - }); |
| 38 | + cy.mount(<Spinner aria-label={ariaLabel} />); |
| 39 | + cy.then(() => ReactDOM.unmountComponentAtNode(getContainerEl())); |
| 40 | + cy.get("body").should("announce", `finished ${ariaLabel}`); |
41 | 41 | }); |
42 | 42 |
|
43 | 43 | it.skip("THEN nothing should be announced when announcer is disabled", () => { |
44 | | - cy.mount(<Spinner aria-label={ariaLabel} disableAnnouncer />).then( |
45 | | - ({ unmount }) => { |
46 | | - cy.findByRole("img").should("not.announce", ariaLabel); |
47 | | - unmount().then(() => { |
48 | | - cy.findByRole("img").should("not.announce", `finished ${ariaLabel}`); |
49 | | - }); |
50 | | - } |
51 | | - ); |
| 44 | + cy.mount(<Spinner aria-label={ariaLabel} disableAnnouncer />); |
| 45 | + cy.findByRole("img").should("not.announce", ariaLabel); |
| 46 | + cy.then(() => ReactDOM.unmountComponentAtNode(getContainerEl())); |
| 47 | + cy.findByRole("img").should("not.announce", `finished ${ariaLabel}`); |
52 | 48 | }); |
53 | 49 |
|
54 | 50 | it.skip("THEN it should not announce completion message when set to null", () => { |
55 | | - cy.mount( |
56 | | - <Spinner aria-label={ariaLabel} completionAnnouncement={null} /> |
57 | | - ).then(({ unmount }) => { |
58 | | - unmount().then(() => { |
59 | | - cy.findByRole("img").should("not.announce", `finished ${ariaLabel}`); |
60 | | - }); |
61 | | - }); |
| 51 | + cy.mount(<Spinner aria-label={ariaLabel} completionAnnouncement={null} />); |
| 52 | + |
| 53 | + cy.then(() => ReactDOM.unmountComponentAtNode(getContainerEl())); |
| 54 | + cy.findByRole("img").should("not.announce", `finished ${ariaLabel}`); |
62 | 55 | }); |
63 | 56 | }); |
0 commit comments