From d46c89fd1b3ea543b202ef3123a13f4cfffc0d78 Mon Sep 17 00:00:00 2001 From: Zachary Dowell Date: Fri, 28 Jul 2023 00:00:58 -0400 Subject: [PATCH] added tests for header --- package.json | 5 +- src/components/Header/Header.test.js | 17 ++++ src/components/Header/HeaderLinks.test.js | 22 +++++ .../Header/__snapshots__/Header.test.js.snap | 51 ++++++++++++ .../__snapshots__/HeaderLinks.test.js.snap | 83 +++++++++++++++++++ 5 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 src/components/Header/Header.test.js create mode 100644 src/components/Header/HeaderLinks.test.js create mode 100644 src/components/Header/__snapshots__/Header.test.js.snap create mode 100644 src/components/Header/__snapshots__/HeaderLinks.test.js.snap diff --git a/package.json b/package.json index 0671fd2..4faddc4 100755 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "history": "4.9.0", "js-beautify": "^1.10.2", "moment": "^2.29.4", - "node-sass": "^4.13.1", "nouislider": "14.0.2", "prop-types": "15.7.2", "react": "16.9.0", @@ -25,7 +24,8 @@ "react-scripts": "^3.3.0", "react-slick": "0.25.2", "react-splitter-layout": "^4.0.0", - "redux": "^4.0.5" + "redux": "^4.0.5", + "sass": "^1.64.1" }, "devDependencies": { "@babel/cli": "^7.19.3", @@ -41,6 +41,7 @@ "gulp-append-prepend": "1.0.8", "jest": "^24.9.0", "prettier": "1.18.2", + "react-test-renderer": "16.9", "ts-jest": "^29.0.3" }, "optionalDependencies": { diff --git a/src/components/Header/Header.test.js b/src/components/Header/Header.test.js new file mode 100644 index 0000000..2d1c157 --- /dev/null +++ b/src/components/Header/Header.test.js @@ -0,0 +1,17 @@ +import React from 'react'; +import renderer from 'react-test-renderer'; +import { BrowserRouter as Router } from 'react-router-dom'; +import Header from './Header'; + +describe("Header", () => { + it("renders correctly", () => { + const tree = renderer + .create( + +
+ + ) + .toJSON(); + expect(tree).toMatchSnapshot(); + }); +}); diff --git a/src/components/Header/HeaderLinks.test.js b/src/components/Header/HeaderLinks.test.js new file mode 100644 index 0000000..72707e9 --- /dev/null +++ b/src/components/Header/HeaderLinks.test.js @@ -0,0 +1,22 @@ +import React from "react"; +import { BrowserRouter as Router } from "react-router-dom/cjs/react-router-dom.min"; +import { render, screen } from "@testing-library/react"; +import "@testing-library/jest-dom"; +import HeaderLinks from "./HeaderLinks"; + + +describe("HeaderLinks", () => { + it("renders snapshot", () => { + const { container } = render(); + expect(container).toMatchSnapshot(); + }); + it("renders HeaderLinks", () => { + render( + + + + ); + expect(screen.getByText("Playground")).toBeInTheDocument(); + expect(screen.getByText("About")).toBeInTheDocument(); + }); +}); diff --git a/src/components/Header/__snapshots__/Header.test.js.snap b/src/components/Header/__snapshots__/Header.test.js.snap new file mode 100644 index 0000000..084873b --- /dev/null +++ b/src/components/Header/__snapshots__/Header.test.js.snap @@ -0,0 +1,51 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Header renders correctly 1`] = ` +
+
+ +
+
+
+`; diff --git a/src/components/Header/__snapshots__/HeaderLinks.test.js.snap b/src/components/Header/__snapshots__/HeaderLinks.test.js.snap new file mode 100644 index 0000000..a256bbc --- /dev/null +++ b/src/components/Header/__snapshots__/HeaderLinks.test.js.snap @@ -0,0 +1,83 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`HeaderLinks renders snapshot 1`] = ` +
+ +
+`;