From 7cccbd50955f1eee7bd14b2a1a3aa5248361fb4a Mon Sep 17 00:00:00 2001 From: phntxx Date: Wed, 23 Jun 2021 12:25:10 +0200 Subject: [PATCH] Update tests --- package.json | 12 ++--- src/app.tsx | 2 +- src/test/__snapshots__/app.spec.tsx.snap | 3 ++ src/test/app.spec.tsx | 9 ++++ .../__snapshots__/app.spec.tsx.snap | 6 ++- src/test/components/app.spec.tsx | 52 ++++++++++++++----- 6 files changed, 61 insertions(+), 23 deletions(-) create mode 100644 src/test/__snapshots__/app.spec.tsx.snap create mode 100644 src/test/app.spec.tsx diff --git a/package.json b/package.json index 9f5afc2..d5bf6a7 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,7 @@ "version": "1.0.0", "license": "MIT", "repository": "git@github.com:phntxx/dashboard", - "contributors": [ - "phntxx " - ], + "contributors": ["phntxx "], "private": false, "dependencies": { "@types/node": "^14.14.37", @@ -36,7 +34,7 @@ "start": "react-scripts start", "build": "react-scripts build", "coverage": "codecov -f coverage/*.json -F dashboard", - "test": "react-scripts test", + "test": "react-scripts test --watchAll --coverage --runInBand", "typecheck": "tsc --noEmit", "eject": "react-scripts eject", "lint": "eslint --config .eslintrc.js", @@ -49,11 +47,7 @@ "extends": "react-app" }, "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], + "production": [">0.2%", "not dead", "not op_mini all"], "development": [ "last 1 chrome version", "last 1 firefox version", diff --git a/src/app.tsx b/src/app.tsx index da2f2d5..7d8e533 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -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; diff --git a/src/test/__snapshots__/app.spec.tsx.snap b/src/test/__snapshots__/app.spec.tsx.snap new file mode 100644 index 0000000..7934f40 --- /dev/null +++ b/src/test/__snapshots__/app.spec.tsx.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`app.tsx Tests GlobalStyle 1`] = `[Function]`; diff --git a/src/test/app.spec.tsx b/src/test/app.spec.tsx new file mode 100644 index 0000000..953f39c --- /dev/null +++ b/src/test/app.spec.tsx @@ -0,0 +1,9 @@ +import { render } from "@testing-library/react"; +import App, { GlobalStyle } from "../app"; + +describe("app.tsx", () => { + it("Tests GlobalStyle", () => { + const { asFragment } = render(); + expect(asFragment).toMatchSnapshot(); + }); +}); diff --git a/src/test/components/__snapshots__/app.spec.tsx.snap b/src/test/components/__snapshots__/app.spec.tsx.snap index 8935f25..7ffd871 100644 --- a/src/test/components/__snapshots__/app.spec.tsx.snap +++ b/src/test/components/__snapshots__/app.spec.tsx.snap @@ -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]`; diff --git a/src/test/components/app.spec.tsx b/src/test/components/app.spec.tsx index b275382..bf7c2ba 100644 --- a/src/test/components/app.spec.tsx +++ b/src/test/components/app.spec.tsx @@ -6,19 +6,47 @@ const props: IAppProps = { icon: "bug_report", url: "#", displayURL: "test", - newTab: false, }; -it("App snapshot test", () => { - const { asFragment } = render( - , - ); +describe("app.tsx", () => { + it("Tests app rendering with newTab=true", () => { + const { asFragment } = render( + , + ); - expect(asFragment).toMatchSnapshot(); + expect(asFragment).toMatchSnapshot(); + }); + + it("Tests app rendering with newTab=false", () => { + const { asFragment } = render( + , + ); + + expect(asFragment).toMatchSnapshot(); + }); + + it("Tests app rendering without newTab", () => { + const { asFragment } = render( + , + ); + + expect(asFragment).toMatchSnapshot(); + }); });