aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/pages/CallbackPage.test.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/pages/CallbackPage.test.tsx')
-rw-r--r--src/tests/pages/CallbackPage.test.tsx23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/tests/pages/CallbackPage.test.tsx b/src/tests/pages/CallbackPage.test.tsx
new file mode 100644
index 0000000..e878577
--- /dev/null
+++ b/src/tests/pages/CallbackPage.test.tsx
@@ -0,0 +1,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()
+ }
+
+ let mockLocation = new URL("https://forms.pythondiscord.com/authorize?code=abcdef");
+
+ Object.defineProperty(global, "location", {value: mockLocation})
+
+ let comp = <CallbackPage />;
+
+ const { getByText } = render(comp);
+
+
+ let codeText = getByText(/Code is abcdef/);
+ expect(codeText).toBeInTheDocument();
+ expect(global.opener.postMessage).toBeCalledTimes(1)
+});