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/CallbackPage.test.tsx | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

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

diff --git a/src/tests/pages/CallbackPage.test.tsx b/src/tests/pages/CallbackPage.test.tsx
index 37fb932..d251772 100644
--- a/src/tests/pages/CallbackPage.test.tsx
+++ b/src/tests/pages/CallbackPage.test.tsx
@@ -1,24 +1,23 @@
 import React from "react";
-import { render, waitFor } from "@testing-library/react";
+import {act, render} from "@testing-library/react";
 
 import CallbackPage from "../../pages/CallbackPage";
 
-test("callback page sends provided code", async () => {
+test("callback page sends provided code", () => {
     global.opener = {
         postMessage: jest.fn()
     };
 
     const mockLocation = new URL("https://forms.pythondiscord.com/authorize?code=abcde_code&state=abcde_state");
 
-    Object.defineProperty(global, "location", {value: mockLocation});
-
-    render(<CallbackPage/>);
+    act(() => {
+        Object.defineProperty(global, "location", {value: mockLocation});
+        render(<CallbackPage/>);
+    });
 
-    await waitFor(() => {
-        expect(global.opener.postMessage).toBeCalledTimes(1);
-        expect(global.opener.postMessage).toBeCalledWith({
-            code: "abcde_code",
-            state: "abcde_state"
-        });
+    expect(global.opener.postMessage).toBeCalledTimes(1);
+    expect(global.opener.postMessage).toBeCalledWith({
+        code: "abcde_code",
+        state: "abcde_state"
     });
 });
-- 
cgit v1.2.3

