diff options
Diffstat (limited to 'src/tests/pages/CallbackPage.test.tsx')
-rw-r--r-- | src/tests/pages/CallbackPage.test.tsx | 21 |
1 files changed, 10 insertions, 11 deletions
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" }); }); |