aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/pages/LandingPage.test.tsx
blob: 908feed2e5400de71314e9be8249e86d862d5d93 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React from "react";
import {act, render, screen} from "@testing-library/react";

import LandingPage from "../../pages/LandingPage";
import * as forms from "../../api/forms";

import {MemoryRouter} 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": {},
            required: true
        }
    ],
    "webhook": null,
    submitted_text: null
};

jest.mock("../../api/forms", () => ({
    ...jest.requireActual("../../api/forms"),
    getForms: jest.fn(() => Promise.resolve([testingForm]))
}));

test("renders landing page", async () => {
    act(() => { render(<LandingPage/>, {wrapper: MemoryRouter}); });
    const headerBar = await screen.findByText(/Python Discord Forms/);
    expect(headerBar).toBeInTheDocument();
});