blob: 9049ca30dcd459f07bb5d1aa35db7edb5847a16c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import React from "react";
import { render } from "@testing-library/react";
import CallbackPage from "../../pages/CallbackPage";
test("callback page renders provided code", () => {
global.opener = {
postMessage: jest.fn()
};
const mockLocation = new URL("https://forms.pythondiscord.com/authorize?code=abcdef");
Object.defineProperty(global, "location", {value: mockLocation});
const comp = <CallbackPage />;
const { getByText } = render(comp);
const codeText = getByText(/Code is abcdef/);
expect(codeText).toBeInTheDocument();
expect(global.opener.postMessage).toBeCalledTimes(1);
});
|