aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2021-02-13 00:26:45 +0300
committerGravatar Hassan Abouelela <[email protected]>2021-02-13 01:16:31 +0300
commit0309638909fe5b107366ff8e288ca25352221677 (patch)
tree0e111b7fbdefbf43d5edcbcb22df1f21b19871b6 /src/tests
parentMerge pull request #133 from python-discord/github-annotations-eslint (diff)
Adds Basic Auth Functionality
Moves all authorization functionality to a new file, and adds a helper to send discord OAuth code to the backend, and set JWT. Adds a library to read and set cookies. Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/pages/CallbackPage.test.tsx15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/tests/pages/CallbackPage.test.tsx b/src/tests/pages/CallbackPage.test.tsx
index 9049ca3..70f2fed 100644
--- a/src/tests/pages/CallbackPage.test.tsx
+++ b/src/tests/pages/CallbackPage.test.tsx
@@ -3,21 +3,20 @@ import { render } from "@testing-library/react";
import CallbackPage from "../../pages/CallbackPage";
-test("callback page renders provided code", () => {
+test("callback page sends provided code", () => {
global.opener = {
postMessage: jest.fn()
};
- const mockLocation = new URL("https://forms.pythondiscord.com/authorize?code=abcdef");
+ const mockLocation = new URL("https://forms.pythondiscord.com/authorize?code=abcde_code&state=abcde_state");
Object.defineProperty(global, "location", {value: mockLocation});
- const comp = <CallbackPage />;
+ render(<CallbackPage/>);
- const { getByText } = render(comp);
-
-
- const codeText = getByText(/Code is abcdef/);
- expect(codeText).toBeInTheDocument();
expect(global.opener.postMessage).toBeCalledTimes(1);
+ expect(global.opener.postMessage).toBeCalledWith({
+ code: "abcde_code",
+ state: "abcde_state"
+ });
});