Skip to content

Commit

Permalink
Merge pull request #67 from COSC-499-W2023/gh-65-frontend-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
connordoman authored Oct 31, 2023
2 parents 16a5a80 + c0f4832 commit d4b926c
Show file tree
Hide file tree
Showing 15 changed files with 573 additions and 120 deletions.
42 changes: 42 additions & 0 deletions app/front-end/__tests__/Footer.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Created on Mon Oct 30 2023
* Author: Connor Doman
*/

import "@testing-library/jest-dom";
import { render, screen } from "@testing-library/react";
import { Footer } from "@components/Footer";

describe("Footer", () => {
it("matches snapshot", () => {
const wrapper = render(<Footer />);
expect(wrapper).toMatchSnapshot();
});

it("contains an HTML footer element", () => {
render(<Footer />);
expect(screen.getByRole("contentinfo")).toBeInTheDocument();
});

it("renders the site logo", () => {
render(<Footer />);
const logo = screen.getByRole("link", { name: "PrivacyPal logo" });
expect(logo).toBeInTheDocument();
expect(logo).toHaveAttribute("href", "/");
});

it("renders the site links", () => {
render(<Footer />);
expect(screen.getByRole("link", { name: "Welcome" })).toBeInTheDocument();
expect(screen.getByRole("link", { name: "About Us" })).toBeInTheDocument();
expect(screen.getByRole("link", { name: "Sign Up" })).toBeInTheDocument();
expect(screen.getByRole("link", { name: "Log in" })).toBeInTheDocument();
});

it("renders social media links", () => {
render(<Footer />);
expect(screen.getByRole("link", { name: "GitHub logo" })).toBeInTheDocument();
expect(screen.getByRole("link", { name: "YouTube logo" })).toBeInTheDocument();
expect(screen.getByRole("link", { name: "mail icon" })).toBeInTheDocument();
});
});
30 changes: 30 additions & 0 deletions app/front-end/__tests__/Header.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Created on Mon Oct 30 2023
* Author: Connor Doman
*/

import "@testing-library/jest-dom";
import { render, screen } from "@testing-library/react";
import { Header } from "@components/Header";

describe("Header", () => {
it("matches snapshot", () => {
const wrapper = render(<Header />);
expect(wrapper).toMatchSnapshot();
});

it("contains an HTML header element", () => {
render(<Header />);
expect(screen.getByRole("banner")).toBeInTheDocument();
});

it("renders the header", () => {
render(<Header />);
expect(screen.getByRole("heading", { name: "A SOLUTION TO ABSOLUTE PRIVACY." })).toBeInTheDocument();
});

it("renders the header image", () => {
render(<Header />);
expect(screen.getByRole("img", { name: "logo" })).toBeInTheDocument();
});
});
284 changes: 284 additions & 0 deletions app/front-end/__tests__/__snapshots__/Footer.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Footer matches snapshot 1`] = `
{
"asFragment": [Function],
"baseElement": <body>
<div>
<footer
class="site-footer"
>
<div
class="footer-item"
>
<a
href="/"
>
<img
alt="PrivacyPal logo"
class="footer-logo"
data-nimg="1"
decoding="async"
height="40"
loading="lazy"
src="/_next/image?url=%2Fimg.jpg&w=96&q=75"
srcset="/_next/image?url=%2Fimg.jpg&w=48&q=75 1x, /_next/image?url=%2Fimg.jpg&w=96&q=75 2x"
style="color: transparent;"
width="40"
/>
</a>
</div>
<div
class="footer-item"
>
Other Sites:
<div
class="footer-links"
>
<a
href="#welcomepage"
>
Welcome
</a>
<a
href="#aboutus"
>
About Us
</a>
<a
href="#signup"
>
Sign Up
</a>
<span>
|
</span>
<a
href="/login"
>
Log in
</a>
</div>
</div>
<div
class="footer-item"
>
<div
class="contact"
>
Follow Us
<a
href="https://github.com/COSC-499-W2023/year-long-project-team-1"
>
<img
alt="GitHub logo"
data-nimg="1"
decoding="async"
height="40"
loading="lazy"
src="/_next/image?url=%2Fimg.jpg&w=96&q=75"
srcset="/_next/image?url=%2Fimg.jpg&w=48&q=75 1x, /_next/image?url=%2Fimg.jpg&w=96&q=75 2x"
style="color: transparent;"
width="40"
/>
</a>
<a
href="#youtube"
>
<img
alt="YouTube logo"
data-nimg="1"
decoding="async"
height="40"
loading="lazy"
src="/_next/image?url=%2Fimg.jpg&w=96&q=75"
srcset="/_next/image?url=%2Fimg.jpg&w=48&q=75 1x, /_next/image?url=%2Fimg.jpg&w=96&q=75 2x"
style="color: transparent;"
width="40"
/>
</a>
<a
href="#Email"
>
<img
alt="mail icon"
data-nimg="1"
decoding="async"
height="40"
loading="lazy"
src="/_next/image?url=%2Fimg.jpg&w=96&q=75"
srcset="/_next/image?url=%2Fimg.jpg&w=48&q=75 1x, /_next/image?url=%2Fimg.jpg&w=96&q=75 2x"
style="color: transparent;"
width="40"
/>
</a>
</div>
</div>
</footer>
</div>
</body>,
"container": <div>
<footer
class="site-footer"
>
<div
class="footer-item"
>
<a
href="/"
>
<img
alt="PrivacyPal logo"
class="footer-logo"
data-nimg="1"
decoding="async"
height="40"
loading="lazy"
src="/_next/image?url=%2Fimg.jpg&w=96&q=75"
srcset="/_next/image?url=%2Fimg.jpg&w=48&q=75 1x, /_next/image?url=%2Fimg.jpg&w=96&q=75 2x"
style="color: transparent;"
width="40"
/>
</a>
</div>
<div
class="footer-item"
>
Other Sites:
<div
class="footer-links"
>
<a
href="#welcomepage"
>
Welcome
</a>
<a
href="#aboutus"
>
About Us
</a>
<a
href="#signup"
>
Sign Up
</a>
<span>
|
</span>
<a
href="/login"
>
Log in
</a>
</div>
</div>
<div
class="footer-item"
>
<div
class="contact"
>
Follow Us
<a
href="https://github.com/COSC-499-W2023/year-long-project-team-1"
>
<img
alt="GitHub logo"
data-nimg="1"
decoding="async"
height="40"
loading="lazy"
src="/_next/image?url=%2Fimg.jpg&w=96&q=75"
srcset="/_next/image?url=%2Fimg.jpg&w=48&q=75 1x, /_next/image?url=%2Fimg.jpg&w=96&q=75 2x"
style="color: transparent;"
width="40"
/>
</a>
<a
href="#youtube"
>
<img
alt="YouTube logo"
data-nimg="1"
decoding="async"
height="40"
loading="lazy"
src="/_next/image?url=%2Fimg.jpg&w=96&q=75"
srcset="/_next/image?url=%2Fimg.jpg&w=48&q=75 1x, /_next/image?url=%2Fimg.jpg&w=96&q=75 2x"
style="color: transparent;"
width="40"
/>
</a>
<a
href="#Email"
>
<img
alt="mail icon"
data-nimg="1"
decoding="async"
height="40"
loading="lazy"
src="/_next/image?url=%2Fimg.jpg&w=96&q=75"
srcset="/_next/image?url=%2Fimg.jpg&w=48&q=75 1x, /_next/image?url=%2Fimg.jpg&w=96&q=75 2x"
style="color: transparent;"
width="40"
/>
</a>
</div>
</div>
</footer>
</div>,
"debug": [Function],
"findAllByAltText": [Function],
"findAllByDisplayValue": [Function],
"findAllByLabelText": [Function],
"findAllByPlaceholderText": [Function],
"findAllByRole": [Function],
"findAllByTestId": [Function],
"findAllByText": [Function],
"findAllByTitle": [Function],
"findByAltText": [Function],
"findByDisplayValue": [Function],
"findByLabelText": [Function],
"findByPlaceholderText": [Function],
"findByRole": [Function],
"findByTestId": [Function],
"findByText": [Function],
"findByTitle": [Function],
"getAllByAltText": [Function],
"getAllByDisplayValue": [Function],
"getAllByLabelText": [Function],
"getAllByPlaceholderText": [Function],
"getAllByRole": [Function],
"getAllByTestId": [Function],
"getAllByText": [Function],
"getAllByTitle": [Function],
"getByAltText": [Function],
"getByDisplayValue": [Function],
"getByLabelText": [Function],
"getByPlaceholderText": [Function],
"getByRole": [Function],
"getByTestId": [Function],
"getByText": [Function],
"getByTitle": [Function],
"queryAllByAltText": [Function],
"queryAllByDisplayValue": [Function],
"queryAllByLabelText": [Function],
"queryAllByPlaceholderText": [Function],
"queryAllByRole": [Function],
"queryAllByTestId": [Function],
"queryAllByText": [Function],
"queryAllByTitle": [Function],
"queryByAltText": [Function],
"queryByDisplayValue": [Function],
"queryByLabelText": [Function],
"queryByPlaceholderText": [Function],
"queryByRole": [Function],
"queryByTestId": [Function],
"queryByText": [Function],
"queryByTitle": [Function],
"rerender": [Function],
"unmount": [Function],
}
`;
Loading

0 comments on commit d4b926c

Please sign in to comment.