diff --git a/package.json b/package.json index ffb0ee9..0d64adf 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "start": "next start", "lint": "next lint", "test": "jest", - "test:watch": "jest --watch" + "test:watch": "jest --watch", + "test:coverage": "jest --coverage" }, "dependencies": { "@nextui-org/react": "^2.4.2", diff --git a/src/__tests__/page.test.tsx b/src/__tests__/page.test.tsx index 8f8a0f7..cb4ac54 100644 --- a/src/__tests__/page.test.tsx +++ b/src/__tests__/page.test.tsx @@ -2,12 +2,28 @@ import "@testing-library/jest-dom"; import { render, screen } from "@testing-library/react"; import Page from "../app/page"; -describe("Page", () => { - it("renders a heading", () => { +describe("Main Page", () => { + it("Renders the proper title and content text", () => { render(); + const timeRegEx = /([0-9]+(:[0-9]+)+)\s[AP]M/i; + + const logo = screen.getByTestId("logo"); const heading = screen.getByRole("heading", { level: 1 }); + const subheader = screen.getByTestId("subheader"); + const location = screen.getByTestId("location"); + const time = screen.getByTestId("time"); + const content = screen.getByTestId("content"); - expect(heading).toBeInTheDocument(); + expect(logo.innerHTML).toEqual("KGM"); + expect(heading.innerHTML).toEqual("Kaj Grant-Mathiasen"); + expect(subheader.innerHTML).toEqual( + "Computer Engineer / Cloud Engineer / Full-Stack Developer" + ); + expect(location.innerHTML).toContain("Vancouver, BC. Canada"); + expect(time.innerHTML).toMatch(timeRegEx); + expect(content.innerHTML).toEqual( + "Currently an Associate Cloud Support Engineer @ Canonical" + ); }); }); diff --git a/src/components/content.tsx b/src/components/content.tsx index 259b506..03a3cf9 100644 --- a/src/components/content.tsx +++ b/src/components/content.tsx @@ -30,7 +30,10 @@ export function Content() {
-

+

Currently an Associate Cloud Support Engineer @ Canonical

diff --git a/src/components/header.tsx b/src/components/header.tsx index ece1d04..79e849b 100644 --- a/src/components/header.tsx +++ b/src/components/header.tsx @@ -3,14 +3,12 @@ import { Location } from "./location"; import { Time } from "./time"; import { brushData } from "@/data/svg/brush"; -export function Header(props: { text?: string; subheader?: string }) { - const text = props.text ? props.text : "Kaj Grant-Mathiasen"; - +export function Header() { return (

- {text} + Kaj Grant-Mathiasen

-

+

Computer Engineer / Cloud Engineer / Full-Stack Developer

diff --git a/src/components/location.tsx b/src/components/location.tsx index 28b0874..99b362f 100644 --- a/src/components/location.tsx +++ b/src/components/location.tsx @@ -8,7 +8,10 @@ export function Location(props: { location: string; locLink: string }) { > -

+

{location}

diff --git a/src/components/logo.tsx b/src/components/logo.tsx index a9dc6c2..ede7ec6 100644 --- a/src/components/logo.tsx +++ b/src/components/logo.tsx @@ -6,7 +6,10 @@ export function Logo(props: { children: React.ReactNode }) {
-

+

{props.children}

diff --git a/src/components/time.tsx b/src/components/time.tsx index 6cbc912..76d35b5 100644 --- a/src/components/time.tsx +++ b/src/components/time.tsx @@ -14,11 +14,12 @@ export function Time(props: { timeZone: string }) { return (
-

+

{date.toLocaleTimeString("en-US", { - timeZone: props.timeZone - ? props.timeZone - : Intl.DateTimeFormat().resolvedOptions().timeZone, + timeZone: props.timeZone, })}