aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/pages/LandingPage.test.tsx
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2022-06-23 15:05:31 +0400
committerGravatar GitHub <[email protected]>2022-06-23 15:05:31 +0400
commit7aa707daa1b4cfe9f2dedcc4e27d3b3a8600e79c (patch)
treebcae8de0d1d1f0488323b4e7d4cf2e1d19db7a5a /src/tests/pages/LandingPage.test.tsx
parentMerge pull request #453 from DavinderJolly/snekbox-results-feedback (diff)
parentBump Webpack Dev Server To 4.9.2 (diff)
Merge pull request #454 from python-discord/bump-dependencies
Bump Dependencies
Diffstat (limited to 'src/tests/pages/LandingPage.test.tsx')
-rw-r--r--src/tests/pages/LandingPage.test.tsx21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/tests/pages/LandingPage.test.tsx b/src/tests/pages/LandingPage.test.tsx
index 6f8a530..727b922 100644
--- a/src/tests/pages/LandingPage.test.tsx
+++ b/src/tests/pages/LandingPage.test.tsx
@@ -1,10 +1,10 @@
import React from "react";
-import { render } from "@testing-library/react";
+import { render, waitFor } from "@testing-library/react";
import LandingPage from "../../pages/LandingPage";
import * as forms from "../../api/forms";
-import { BrowserRouter as Router } from "react-router-dom";
+import { MemoryRouter } from "react-router-dom";
import { QuestionType } from "../../api/question";
const testingForm: forms.Form = {
@@ -25,13 +25,12 @@ const testingForm: forms.Form = {
submitted_text: null
};
-test("renders landing page", () => {
- const setForms = jest.fn(() => [testingForm]);
- Object.defineProperty(forms, "getForms", setForms);
- const handleForms = jest.spyOn(React, "useState");
- handleForms.mockImplementation(() => [[testingForm], setForms]);
- const { getByText } = render(<Router><LandingPage /></Router>);
- // If we rendered the headerbar we rendered the landing page.
- const headerBar = getByText(/Python Discord Forms/);
- expect(headerBar).toBeInTheDocument();
+test("renders landing page", async () => {
+ jest.spyOn(forms, "getForms").mockImplementation(() => Promise.resolve([testingForm]));
+
+ const { getByText } = render(<LandingPage/>, {wrapper: MemoryRouter});
+ await waitFor(() => {
+ const headerBar = getByText(/Python Discord Forms/);
+ expect(headerBar).toBeInTheDocument();
+ });
});