aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/pages/CallbackPage.test.tsx
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2022-07-14 10:36:10 +0400
committerGravatar GitHub <[email protected]>2022-07-14 10:36:10 +0400
commitf2a4307467c4ce0e6d23a97c382d714ed955732b (patch)
tree3a23e602e06edc57b02f4d37050f280e04360536 /src/tests/pages/CallbackPage.test.tsx
parentMerge pull request #477 from python-discord/update-refresh-timeout-logic (diff)
parentFix Failing jest.spyOn (diff)
Merge pull request #483 from python-discord/dependabot/npm_and_yarn/swc/core-1.2.213
Bump @swc/core from 1.2.204 to 1.2.213
Diffstat (limited to 'src/tests/pages/CallbackPage.test.tsx')
-rw-r--r--src/tests/pages/CallbackPage.test.tsx21
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"
});
});