From 5f4ddc8fd7d84500457bb08b0981a84a2d1594b1 Mon Sep 17 00:00:00 2001
From: Hassan Abouelela <hassan@hassanamr.com>
Date: Sat, 18 Jun 2022 23:59:14 +0400
Subject: Bump React To 18.2.0

Bump react to v18, and handle all the breaking changes. This includes
bumping a lot of other dependencies to versions which support react 18,
and handling the breaking changes for those.

Refer to the following documents for migration guides:
React: https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html
Router: https://reactrouter.com/docs/en/v6/upgrading/v5

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
---
 src/tests/pages/LandingPage.test.tsx | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

(limited to 'src/tests/pages/LandingPage.test.tsx')

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();
+    });
 });
-- 
cgit v1.2.3

