From 83ad168cfe0f5865c4538e0b9bb98173e0c0a07e Mon Sep 17 00:00:00 2001
From: Hassan Abouelela <hassan@hassanamr.com>
Date: Thu, 14 Jul 2022 09:12:52 +0400
Subject: Wrap Tests In Act

Wrap the tests that were raising warnings in act statements.

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
---
 src/tests/pages/FormPage.test.tsx | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

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

diff --git a/src/tests/pages/FormPage.test.tsx b/src/tests/pages/FormPage.test.tsx
index bd297ec..d5b1999 100644
--- a/src/tests/pages/FormPage.test.tsx
+++ b/src/tests/pages/FormPage.test.tsx
@@ -1,15 +1,15 @@
 import React from "react";
-import { render } from "@testing-library/react";
+import {act, render, screen} from "@testing-library/react";
 
-import { MemoryRouter } from "react-router-dom";
+import {MemoryRouter} from "react-router-dom";
 import FormPage from "../../pages/FormPage/FormPage";
 
 import * as forms from "../../api/forms";
 
 test("renders specific form page with loading bar", () => {
-    const { getByText } = render(<FormPage/>, {wrapper: MemoryRouter});
+    act(() => { render(<FormPage/>, {wrapper: MemoryRouter}); });
     // If we rendered the headerbar we rendered the forms page.
-    const headerBar = getByText(/Loading.../);
+    const headerBar = screen.getByText(/Loading.../);
     expect(headerBar).toBeInTheDocument();
 });
 
@@ -17,9 +17,10 @@ test("renders specific form page with loading bar", () => {
 test.skip("calls api method to load form", () => {
     const oldImpl = forms.getForm;
 
-    Object.defineProperty(forms, "getForm", {value: jest.fn(oldImpl)});
-
-    render(<FormPage/>, {wrapper: MemoryRouter});
+    act(() => {
+        Object.defineProperty(forms, "getForm", {value: jest.fn(oldImpl)});
+        render(<FormPage/>, {wrapper: MemoryRouter});
+    });
 
     expect(forms.getForm).toBeCalled();
 });
-- 
cgit v1.2.3

