From 3adfb0db3493a55276b126bdbcb343da89218601 Mon Sep 17 00:00:00 2001
From: Joe Banks <joseph@josephbanks.me>
Date: Mon, 12 Oct 2020 17:56:49 +0100
Subject: Add many new tests

---
 src/tests/pages/CallbackPage.test.tsx | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 src/tests/pages/CallbackPage.test.tsx

(limited to 'src/tests/pages/CallbackPage.test.tsx')

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)
+});
-- 
cgit v1.2.3

