|
1 |
| -import { screen, waitFor } from "@testing-library/react" |
2 |
| -import App from "./App" |
3 |
| -import { renderWithProviders } from "./utils/test-utils" |
| 1 | +import { screen, fireEvent } from "@testing-library/react"; |
| 2 | +import App from "./App"; |
| 3 | +import { renderWithProviders } from "./utils/test-utils"; |
4 | 4 |
|
5 |
| -test("App should have correct initial render", () => { |
6 |
| - renderWithProviders(<App />) |
| 5 | +// TODO: enable this once we work out how to mock viewport width |
| 6 | +// test("App should have correct initial render on desktop", () => { |
| 7 | +// window.innerWidth = 1200; |
| 8 | +// fireEvent(window, new Event("resize")); |
7 | 9 |
|
8 |
| - // The app should be rendered correctly |
9 |
| - expect(screen.getByText(/learn/i)).toBeInTheDocument() |
| 10 | +// renderWithProviders(<App />); |
10 | 11 |
|
11 |
| - // Initial state: count should be 0, incrementValue should be 2 |
12 |
| - expect(screen.getByLabelText("Count")).toHaveTextContent("0") |
13 |
| - expect(screen.getByLabelText("Set increment amount")).toHaveValue(2) |
14 |
| -}) |
| 12 | +// expect(screen.getByLabelText("Open panel")).toBeInTheDocument(); |
| 13 | +// }); |
15 | 14 |
|
16 |
| -test("Increment value and Decrement value should work as expected", async () => { |
17 |
| - const { user } = renderWithProviders(<App />) |
| 15 | +test("App should have correct initial render on mobile", () => { |
| 16 | + renderWithProviders(<App />); |
18 | 17 |
|
19 |
| - // Click on "+" => Count should be 1 |
20 |
| - await user.click(screen.getByLabelText("Increment value")) |
21 |
| - expect(screen.getByLabelText("Count")).toHaveTextContent("1") |
| 18 | + expect(screen.getByText("Search")).toBeInTheDocument(); |
| 19 | +}); |
22 | 20 |
|
23 |
| - // Click on "-" => Count should be 0 |
24 |
| - await user.click(screen.getByLabelText("Decrement value")) |
25 |
| - expect(screen.getByLabelText("Count")).toHaveTextContent("0") |
26 |
| -}) |
| 21 | +// test("Increment value and Decrement value should work as expected", async () => { |
| 22 | +// const { user } = renderWithProviders(<App />) |
27 | 23 |
|
28 |
| -test("Add Amount should work as expected", async () => { |
29 |
| - const { user } = renderWithProviders(<App />) |
| 24 | +// // Click on "+" => Count should be 1 |
| 25 | +// await user.click(screen.getByLabelText("Increment value")) |
| 26 | +// expect(screen.getByLabelText("Count")).toHaveTextContent("1") |
30 | 27 |
|
31 |
| - // "Add Amount" button is clicked => Count should be 2 |
32 |
| - await user.click(screen.getByText("Add Amount")) |
33 |
| - expect(screen.getByLabelText("Count")).toHaveTextContent("2") |
34 |
| - |
35 |
| - const incrementValueInput = screen.getByLabelText("Set increment amount") |
36 |
| - // incrementValue is 2, click on "Add Amount" => Count should be 4 |
37 |
| - await user.clear(incrementValueInput) |
38 |
| - await user.type(incrementValueInput, "2") |
39 |
| - await user.click(screen.getByText("Add Amount")) |
40 |
| - expect(screen.getByLabelText("Count")).toHaveTextContent("4") |
41 |
| - |
42 |
| - // [Negative number] incrementValue is -1, click on "Add Amount" => Count should be 3 |
43 |
| - await user.clear(incrementValueInput) |
44 |
| - await user.type(incrementValueInput, "-1") |
45 |
| - await user.click(screen.getByText("Add Amount")) |
46 |
| - expect(screen.getByLabelText("Count")).toHaveTextContent("3") |
47 |
| -}) |
48 |
| - |
49 |
| -it("Add Async should work as expected", async () => { |
50 |
| - const { user } = renderWithProviders(<App />) |
51 |
| - |
52 |
| - // "Add Async" button is clicked => Count should be 2 |
53 |
| - await user.click(screen.getByText("Add Async")) |
54 |
| - |
55 |
| - await waitFor(() => |
56 |
| - expect(screen.getByLabelText("Count")).toHaveTextContent("2"), |
57 |
| - ) |
58 |
| - |
59 |
| - const incrementValueInput = screen.getByLabelText("Set increment amount") |
60 |
| - // incrementValue is 2, click on "Add Async" => Count should be 4 |
61 |
| - await user.clear(incrementValueInput) |
62 |
| - await user.type(incrementValueInput, "2") |
63 |
| - |
64 |
| - await user.click(screen.getByText("Add Async")) |
65 |
| - await waitFor(() => |
66 |
| - expect(screen.getByLabelText("Count")).toHaveTextContent("4"), |
67 |
| - ) |
68 |
| - |
69 |
| - // [Negative number] incrementValue is -1, click on "Add Async" => Count should be 3 |
70 |
| - await user.clear(incrementValueInput) |
71 |
| - await user.type(incrementValueInput, "-1") |
72 |
| - await user.click(screen.getByText("Add Async")) |
73 |
| - await waitFor(() => |
74 |
| - expect(screen.getByLabelText("Count")).toHaveTextContent("3"), |
75 |
| - ) |
76 |
| -}) |
77 |
| - |
78 |
| -test("Add If Odd should work as expected", async () => { |
79 |
| - const { user } = renderWithProviders(<App />) |
80 |
| - |
81 |
| - // "Add If Odd" button is clicked => Count should stay 0 |
82 |
| - await user.click(screen.getByText("Add If Odd")) |
83 |
| - expect(screen.getByLabelText("Count")).toHaveTextContent("0") |
84 |
| - |
85 |
| - // Click on "+" => Count should be updated to 1 |
86 |
| - await user.click(screen.getByLabelText("Increment value")) |
87 |
| - expect(screen.getByLabelText("Count")).toHaveTextContent("1") |
88 |
| - |
89 |
| - // "Add If Odd" button is clicked => Count should be updated to 3 |
90 |
| - await user.click(screen.getByText("Add If Odd")) |
91 |
| - expect(screen.getByLabelText("Count")).toHaveTextContent("3") |
92 |
| - |
93 |
| - const incrementValueInput = screen.getByLabelText("Set increment amount") |
94 |
| - // incrementValue is 1, click on "Add If Odd" => Count should be updated to 4 |
95 |
| - await user.clear(incrementValueInput) |
96 |
| - await user.type(incrementValueInput, "1") |
97 |
| - await user.click(screen.getByText("Add If Odd")) |
98 |
| - expect(screen.getByLabelText("Count")).toHaveTextContent("4") |
99 |
| - |
100 |
| - // click on "Add If Odd" => Count should stay 4 |
101 |
| - await user.clear(incrementValueInput) |
102 |
| - await user.type(incrementValueInput, "-1") |
103 |
| - await user.click(screen.getByText("Add If Odd")) |
104 |
| - expect(screen.getByLabelText("Count")).toHaveTextContent("4") |
105 |
| -}) |
| 28 | +// // Click on "-" => Count should be 0 |
| 29 | +// await user.click(screen.getByLabelText("Decrement value")) |
| 30 | +// expect(screen.getByLabelText("Count")).toHaveTextContent("0") |
| 31 | +// }) |
0 commit comments