diff options
author | 2022-07-14 10:36:10 +0400 | |
---|---|---|
committer | 2022-07-14 10:36:10 +0400 | |
commit | f2a4307467c4ce0e6d23a97c382d714ed955732b (patch) | |
tree | 3a23e602e06edc57b02f4d37050f280e04360536 /src/tests/pages/LandingPage.test.tsx | |
parent | Merge pull request #477 from python-discord/update-refresh-timeout-logic (diff) | |
parent | Fix Failing jest.spyOn (diff) |
Merge pull request #483 from python-discord/dependabot/npm_and_yarn/swc/core-1.2.213
Bump @swc/core from 1.2.204 to 1.2.213
Diffstat (limited to 'src/tests/pages/LandingPage.test.tsx')
-rw-r--r-- | src/tests/pages/LandingPage.test.tsx | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/tests/pages/LandingPage.test.tsx b/src/tests/pages/LandingPage.test.tsx index 727b922..908feed 100644 --- a/src/tests/pages/LandingPage.test.tsx +++ b/src/tests/pages/LandingPage.test.tsx @@ -1,11 +1,11 @@ import React from "react"; -import { render, waitFor } from "@testing-library/react"; +import {act, render, screen} from "@testing-library/react"; import LandingPage from "../../pages/LandingPage"; import * as forms from "../../api/forms"; -import { MemoryRouter } from "react-router-dom"; -import { QuestionType } from "../../api/question"; +import {MemoryRouter} from "react-router-dom"; +import {QuestionType} from "../../api/question"; const testingForm: forms.Form = { "id": "testing-form", @@ -25,12 +25,13 @@ const testingForm: forms.Form = { submitted_text: null }; -test("renders landing page", async () => { - jest.spyOn(forms, "getForms").mockImplementation(() => Promise.resolve([testingForm])); +jest.mock("../../api/forms", () => ({ + ...jest.requireActual("../../api/forms"), + getForms: jest.fn(() => Promise.resolve([testingForm])) +})); - const { getByText } = render(<LandingPage/>, {wrapper: MemoryRouter}); - await waitFor(() => { - const headerBar = getByText(/Python Discord Forms/); - expect(headerBar).toBeInTheDocument(); - }); +test("renders landing page", async () => { + act(() => { render(<LandingPage/>, {wrapper: MemoryRouter}); }); + const headerBar = await screen.findByText(/Python Discord Forms/); + expect(headerBar).toBeInTheDocument(); }); |