Update tests

This commit is contained in:
phntxx 2021-06-23 12:25:10 +02:00
parent b95f9667ed
commit 7cccbd5095
6 changed files with 61 additions and 23 deletions

View file

@ -10,7 +10,7 @@ import Imprint from "./components/imprint";
import selectedTheme from "./lib/theme";
import useFetcher from "./lib/fetcher";
const GlobalStyle = createGlobalStyle`
export const GlobalStyle = createGlobalStyle`
body {
background-color: ${selectedTheme.backgroundColor};
font-family: Roboto, sans-serif;

View file

@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`app.tsx Tests GlobalStyle 1`] = `[Function]`;

9
src/test/app.spec.tsx Normal file
View file

@ -0,0 +1,9 @@
import { render } from "@testing-library/react";
import App, { GlobalStyle } from "../app";
describe("app.tsx", () => {
it("Tests GlobalStyle", () => {
const { asFragment } = render(<GlobalStyle />);
expect(asFragment).toMatchSnapshot();
});
});

View file

@ -1,3 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`App snapshot test 1`] = `[Function]`;
exports[`app.tsx Tests app rendering with newTab=false 1`] = `[Function]`;
exports[`app.tsx Tests app rendering with newTab=true 1`] = `[Function]`;
exports[`app.tsx Tests app rendering without newTab 1`] = `[Function]`;

View file

@ -6,19 +6,47 @@ const props: IAppProps = {
icon: "bug_report",
url: "#",
displayURL: "test",
newTab: false,
};
it("App snapshot test", () => {
const { asFragment } = render(
<App
name={props.name}
icon={props.icon}
url={props.url}
displayURL={props.displayURL}
newTab={props.newTab}
/>,
);
describe("app.tsx", () => {
it("Tests app rendering with newTab=true", () => {
const { asFragment } = render(
<App
name={props.name}
icon={props.icon}
url={props.url}
displayURL={props.displayURL}
newTab={true}
/>,
);
expect(asFragment).toMatchSnapshot();
expect(asFragment).toMatchSnapshot();
});
it("Tests app rendering with newTab=false", () => {
const { asFragment } = render(
<App
name={props.name}
icon={props.icon}
url={props.url}
displayURL={props.displayURL}
newTab={false}
/>,
);
expect(asFragment).toMatchSnapshot();
});
it("Tests app rendering without newTab", () => {
const { asFragment } = render(
<App
name={props.name}
icon={props.icon}
url={props.url}
displayURL={props.displayURL}
/>,
);
expect(asFragment).toMatchSnapshot();
});
});