aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/components/OAuth2Button.test.tsx2
-rw-r--r--src/tests/pages/CallbackPage.test.tsx15
2 files changed, 8 insertions, 9 deletions
diff --git a/src/tests/components/OAuth2Button.test.tsx b/src/tests/components/OAuth2Button.test.tsx
index f05159f..a773686 100644
--- a/src/tests/components/OAuth2Button.test.tsx
+++ b/src/tests/components/OAuth2Button.test.tsx
@@ -4,7 +4,7 @@ import OAuth2Button from "../../components/OAuth2Button";
test("renders oauth2 sign in button text", () => {
const { getByText } = render(<OAuth2Button />);
- const button = getByText(/Sign in with Discord/i);
+ const button = getByText(/Discord Login/i);
expect(button).toBeInTheDocument();
});
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"
+ });
});