|
1 | 1 | import { fireEvent, waitFor } from "@testing-library/react"; |
2 | 2 |
|
3 | 3 | import { renderApp } from "../../utils/render-app"; |
| 4 | +import { sleep } from "../../utils"; |
4 | 5 |
|
5 | | -describe("Controls [Base]", () => { |
| 6 | +describe("Controls [Zoom]", () => { |
6 | 7 | describe("When zooming in with controls button", () => { |
7 | | - // it("should increase css scale with animated zoom", async () => { |
8 | | - // const { content, zoomInBtn } = renderApp(); |
9 | | - // expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); |
10 | | - // fireEvent(zoomInBtn, new MouseEvent("click", { bubbles: true })); |
11 | | - // // Animation starts |
12 | | - // expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); |
13 | | - // await waitFor(() => { |
14 | | - // // Animation ends |
15 | | - // expect(content.style.transform).toBe("translate(0px, 0px) scale(1.65)"); |
16 | | - // }); |
17 | | - // }); |
| 8 | + it("should change css scale", async () => { |
| 9 | + const { content, zoomInBtn, centerBtn } = renderApp(); |
| 10 | + expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); |
| 11 | + fireEvent(zoomInBtn, new MouseEvent("click", { bubbles: true })); |
| 12 | + expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); |
| 13 | + await waitFor(() => { |
| 14 | + expect(content.style.transform).toBe( |
| 15 | + "translate(-162.5px, -162.5px) scale(1.65)", |
| 16 | + ); |
| 17 | + }); |
| 18 | + fireEvent(centerBtn, new MouseEvent("click", { bubbles: true })); |
| 19 | + await sleep(40); |
| 20 | + await waitFor(() => { |
| 21 | + expect(content.style.transform).toBe( |
| 22 | + "translate(-162.5px, -162.5px) scale(1.65)", |
| 23 | + ); |
| 24 | + }); |
| 25 | + }); |
| 26 | + }); |
| 27 | + describe("When zooming out with controls button", () => { |
| 28 | + it("should change css scale", async () => { |
| 29 | + const { content, zoomOutBtn, zoom } = renderApp(); |
| 30 | + |
| 31 | + zoom({ value: 1.65 }); |
| 32 | + expect(content.style.transform).toBe("translate(0px, 0px) scale(1.65)"); |
| 33 | + fireEvent(zoomOutBtn, new MouseEvent("click", { bubbles: true })); |
| 34 | + await waitFor(() => { |
| 35 | + expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); |
| 36 | + }); |
| 37 | + }); |
18 | 38 | }); |
19 | 39 | }); |
0 commit comments