aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/App.test.tsx6
-rw-r--r--src/tests/api/forms.test.ts6
-rw-r--r--src/tests/components/FormListing.test.tsx24
-rw-r--r--src/tests/components/HeaderBar.test.tsx10
-rw-r--r--src/tests/components/OAuth2Button.test.tsx10
-rw-r--r--src/tests/components/Tag.test.tsx12
-rw-r--r--src/tests/globalStyles.test.ts2
-rw-r--r--src/tests/pages/CallbackPage.test.tsx20
-rw-r--r--src/tests/pages/FormPage.test.tsx14
-rw-r--r--src/tests/pages/LandingPage.test.tsx14
10 files changed, 59 insertions, 59 deletions
diff --git a/src/tests/App.test.tsx b/src/tests/App.test.tsx
index e050d4f..4765f87 100644
--- a/src/tests/App.test.tsx
+++ b/src/tests/App.test.tsx
@@ -1,9 +1,9 @@
-import React from 'react';
-import { render } from '@testing-library/react';
+import React from "react";
+import { render } from "@testing-library/react";
import App from "../App";
-test('renders app to body', () => {
+test("renders app to body", () => {
const { container } = render(<App />);
expect(container).toBeInTheDocument();
});
diff --git a/src/tests/api/forms.test.ts b/src/tests/api/forms.test.ts
index 6e63965..10ccaa3 100644
--- a/src/tests/api/forms.test.ts
+++ b/src/tests/api/forms.test.ts
@@ -1,7 +1,7 @@
-import { getForm, getForms } from "../../api/forms";
+import { getForm } from "../../api/forms";
-test('fetch a specific form', () => {
- expect(getForm("ban-appeals")).resolves.toHaveProperty("name", "Ban Appeals")
+test("fetch a specific form", () => {
+ expect(getForm("ban-appeals")).resolves.toHaveProperty("name", "Ban Appeals");
});
export default null;
diff --git a/src/tests/components/FormListing.test.tsx b/src/tests/components/FormListing.test.tsx
index 0afe10c..ad76381 100644
--- a/src/tests/components/FormListing.test.tsx
+++ b/src/tests/components/FormListing.test.tsx
@@ -1,11 +1,11 @@
-import React from 'react';
-import { render } from '@testing-library/react';
-import '@testing-library/jest-dom/extend-expect';
+import React from "react";
+import { render } from "@testing-library/react";
+import "@testing-library/jest-dom/extend-expect";
import FormListing from "../../components/FormListing";
-import { BrowserRouter as Router } from 'react-router-dom';
-import { Form, FormFeatures } from '../../api/forms';
-import { QuestionType } from '../../api/question';
+import { BrowserRouter as Router } from "react-router-dom";
+import { Form, FormFeatures } from "../../api/forms";
+import { QuestionType } from "../../api/question";
const openFormListing: Form = {
name: "Example form listing",
@@ -20,7 +20,7 @@ const openFormListing: Form = {
"data": {}
}
]
-}
+};
const closedFormListing: Form = {
name: "Example form listing",
@@ -35,28 +35,28 @@ const closedFormListing: Form = {
"data": {}
}
]
-}
+};
-test('renders form listing with specified title', () => {
+test("renders form listing with specified title", () => {
const { getByText } = render(<Router><FormListing form={openFormListing} /></Router>);
const formListing = getByText(/Example form listing/i);
expect(formListing).toBeInTheDocument();
});
-test('renders form listing with specified description', () => {
+test("renders form listing with specified description", () => {
const { getByText } = render(<Router><FormListing form={openFormListing} /></Router>);
const formListing = getByText(/My form listing/i);
expect(formListing).toBeInTheDocument();
});
-test('renders form listing with background green colour for open', () => {
+test("renders form listing with background green colour for open", () => {
const { container } = render(<Router><FormListing form={openFormListing} /></Router>);
const elem = container.querySelector("a");
const style = window.getComputedStyle(elem);
expect(style.backgroundColor).toBe("rgb(67, 181, 129)");
});
-test('renders form listing with background dark colour for closed', () => {
+test("renders form listing with background dark colour for closed", () => {
const { container } = render(<Router><FormListing form={closedFormListing} /></Router>);
const elem = container.querySelector("a");
const style = window.getComputedStyle(elem);
diff --git a/src/tests/components/HeaderBar.test.tsx b/src/tests/components/HeaderBar.test.tsx
index 6963859..9c232ad 100644
--- a/src/tests/components/HeaderBar.test.tsx
+++ b/src/tests/components/HeaderBar.test.tsx
@@ -1,15 +1,15 @@
-import React from 'react';
-import { render } from '@testing-library/react';
-import '@testing-library/jest-dom/extend-expect'
+import React from "react";
+import { render } from "@testing-library/react";
+import "@testing-library/jest-dom/extend-expect";
import HeaderBar from "../../components/HeaderBar";
-test('renders header bar with title', () => {
+test("renders header bar with title", () => {
const { getByText } = render(<HeaderBar />);
const formListing = getByText(/Python Discord Forms/i);
expect(formListing).toBeInTheDocument();
});
-test('renders header bar with custom title', () => {
+test("renders header bar with custom title", () => {
const { getByText } = render(<HeaderBar title="Testing title"/>);
const formListing = getByText(/Testing title/i);
expect(formListing).toBeInTheDocument();
diff --git a/src/tests/components/OAuth2Button.test.tsx b/src/tests/components/OAuth2Button.test.tsx
index 53875dc..f05159f 100644
--- a/src/tests/components/OAuth2Button.test.tsx
+++ b/src/tests/components/OAuth2Button.test.tsx
@@ -1,8 +1,8 @@
-import React from 'react';
-import { render } from '@testing-library/react';
+import React from "react";
+import { render } from "@testing-library/react";
import OAuth2Button from "../../components/OAuth2Button";
-test('renders oauth2 sign in button text', () => {
+test("renders oauth2 sign in button text", () => {
const { getByText } = render(<OAuth2Button />);
const button = getByText(/Sign in with Discord/i);
expect(button).toBeInTheDocument();
@@ -10,6 +10,6 @@ test('renders oauth2 sign in button text', () => {
test("renders fontawesome discord icon", () => {
const { container } = render(<OAuth2Button/>);
- const icon = container.querySelector(`[data-icon="discord"]`)
+ const icon = container.querySelector("[data-icon=\"discord\"]");
expect(icon).toBeInTheDocument();
-})
+});
diff --git a/src/tests/components/Tag.test.tsx b/src/tests/components/Tag.test.tsx
index 67f2a85..50b3b0e 100644
--- a/src/tests/components/Tag.test.tsx
+++ b/src/tests/components/Tag.test.tsx
@@ -1,28 +1,28 @@
-import React from 'react';
-import { render } from '@testing-library/react';
+import React from "react";
+import { render } from "@testing-library/react";
import Tag from "../../components/Tag";
-test('renders tag with specified text', () => {
+test("renders tag with specified text", () => {
const { getByText } = render(<Tag text="Test" color="#f0f0f0" />);
const tag = getByText(/Test/i);
expect(tag).toBeInTheDocument();
});
-test('renders tag with specified color', () => {
+test("renders tag with specified color", () => {
const { getByText } = render(<Tag text="Test" color="#f0f0f0" />);
const tag = getByText(/Test/i);
const style = window.getComputedStyle(tag);
expect(style.backgroundColor).toBe("rgb(240, 240, 240)");
});
-test('renders tag with specified font size', () => {
+test("renders tag with specified font size", () => {
const { getByText } = render(<Tag text="Test" color="#f0f0f0" fontSize="2em" />);
const tag = getByText(/Test/i);
const style = window.getComputedStyle(tag);
expect(style.fontSize).toBe("2em");
});
-test('defaults to 0.75em when no tag font size is passed', () => {
+test("defaults to 0.75em when no tag font size is passed", () => {
const { getByText } = render(<Tag text="Test" color="#f0f0f0" />);
const tag = getByText(/Test/i);
const style = window.getComputedStyle(tag);
diff --git a/src/tests/globalStyles.test.ts b/src/tests/globalStyles.test.ts
index d44cc51..a7017c8 100644
--- a/src/tests/globalStyles.test.ts
+++ b/src/tests/globalStyles.test.ts
@@ -2,4 +2,4 @@ import globalStyles from "../globalStyles";
test("global styles emotion css compiles", () => {
expect(globalStyles.styles).not.toBeUndefined();
-})
+});
diff --git a/src/tests/pages/CallbackPage.test.tsx b/src/tests/pages/CallbackPage.test.tsx
index e878577..9049ca3 100644
--- a/src/tests/pages/CallbackPage.test.tsx
+++ b/src/tests/pages/CallbackPage.test.tsx
@@ -1,23 +1,23 @@
-import React from 'react';
-import { render } from '@testing-library/react';
+import React from "react";
+import { render } from "@testing-library/react";
-import CallbackPage from '../../pages/CallbackPage';
+import CallbackPage from "../../pages/CallbackPage";
-test('callback page renders provided code', () => {
+test("callback page renders provided code", () => {
global.opener = {
postMessage: jest.fn()
- }
+ };
- let mockLocation = new URL("https://forms.pythondiscord.com/authorize?code=abcdef");
+ const mockLocation = new URL("https://forms.pythondiscord.com/authorize?code=abcdef");
- Object.defineProperty(global, "location", {value: mockLocation})
+ Object.defineProperty(global, "location", {value: mockLocation});
- let comp = <CallbackPage />;
+ const comp = <CallbackPage />;
const { getByText } = render(comp);
- let codeText = getByText(/Code is abcdef/);
+ const codeText = getByText(/Code is abcdef/);
expect(codeText).toBeInTheDocument();
- expect(global.opener.postMessage).toBeCalledTimes(1)
+ expect(global.opener.postMessage).toBeCalledTimes(1);
});
diff --git a/src/tests/pages/FormPage.test.tsx b/src/tests/pages/FormPage.test.tsx
index 7bfc763..f7ecc32 100644
--- a/src/tests/pages/FormPage.test.tsx
+++ b/src/tests/pages/FormPage.test.tsx
@@ -1,28 +1,28 @@
-import React from 'react';
-import { render } from '@testing-library/react';
+import React from "react";
+import { render } from "@testing-library/react";
import { createMemoryHistory } from "history";
import { Route, BrowserRouter as Router } from "react-router-dom";
-import FormPage from '../../pages/FormPage';
+import FormPage from "../../pages/FormPage";
import * as forms from "../../api/forms";
-test('renders specific form page with loading bar', () => {
+test("renders specific form page with loading bar", () => {
const history = createMemoryHistory();
history.push("/form/route");
const { getByText } = render(<Router><Route history={history} ><FormPage /></Route></Router>);
// If we rendered the headerbar we rendered the forms page.
- let headerBar = getByText(/Loading.../);
+ const headerBar = getByText(/Loading.../);
expect(headerBar).toBeInTheDocument();
});
-test('calls api method to load form', () => {
+test("calls api method to load form", () => {
const history = createMemoryHistory();
history.push("/form/ban-appeals");
- let oldImpl = forms.getForm;
+ const oldImpl = forms.getForm;
Object.defineProperty(forms, "getForm", {value: jest.fn(oldImpl)});
diff --git a/src/tests/pages/LandingPage.test.tsx b/src/tests/pages/LandingPage.test.tsx
index 23195bd..5635e63 100644
--- a/src/tests/pages/LandingPage.test.tsx
+++ b/src/tests/pages/LandingPage.test.tsx
@@ -1,11 +1,11 @@
-import React from 'react';
-import { render } from '@testing-library/react';
+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';
+import { QuestionType } from "../../api/question";
const testingForm: forms.Form = {
"id": "testing-form",
@@ -20,15 +20,15 @@ const testingForm: forms.Form = {
"data": {}
}
]
-}
+};
-test('renders landing page', () => {
+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]);
+ handleForms.mockImplementation(() => [[testingForm], setForms]);
const { getByText } = render(<Router><LandingPage /></Router>);
// If we rendered the headerbar we rendered the landing page.
- let headerBar = getByText(/Python Discord Forms/);
+ const headerBar = getByText(/Python Discord Forms/);
expect(headerBar).toBeInTheDocument();
});