From a43fa25ffb3c32a58f6619423bb33eb64c7d2d45 Mon Sep 17 00:00:00 2001
From: ks129 <45097959+ks129@users.noreply.github.com>
Date: Mon, 14 Dec 2020 13:49:14 +0200
Subject: Update tests to match with changes in discovery

---
 src/tests/pages/LandingPage.test.tsx | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

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

diff --git a/src/tests/pages/LandingPage.test.tsx b/src/tests/pages/LandingPage.test.tsx
index ba32bab..23195bd 100644
--- a/src/tests/pages/LandingPage.test.tsx
+++ b/src/tests/pages/LandingPage.test.tsx
@@ -2,10 +2,31 @@ import React from 'react';
 import { render } from '@testing-library/react';
 
 import LandingPage from "../../pages/LandingPage";
+import * as forms from "../../api/forms";
 
 import { BrowserRouter as Router } from "react-router-dom";
+import { QuestionType } from '../../api/question';
+
+const testingForm: forms.Form = {
+    "id": "testing-form",
+    "name": "Testing Form",
+    "description": "Meant for testing",
+    "features": [forms.FormFeatures.Discoverable],
+    "questions": [
+        {
+            "id": "my-question",
+            "name": "My Question",
+            "type": QuestionType.ShortText,
+            "data": {}
+        }
+    ]
+}
 
 test('renders landing page', () => {
+    const setForms = jest.fn(() => [testingForm]);
+    Object.defineProperty(forms, "getForms", setForms);
+    const handleForms = jest.spyOn(React, "useState");
+    handleForms.mockImplementation(_value => [[testingForm], setForms]);
     const { getByText } = render(<Router><LandingPage /></Router>);
     // If we rendered the headerbar we rendered the landing page.
     let headerBar = getByText(/Python Discord Forms/);
-- 
cgit v1.2.3

