From 14187e995c5cdfe57e1624608bf1731b47bffcdf Mon Sep 17 00:00:00 2001
From: Anjali Srivastava
Date: Thu, 11 Jul 2024 22:20:24 -0500
Subject: [PATCH] Unit tests with Jest and React testing
---
app/(root)/__tests__/Home.test.tsx | 37 +
app/(root)/investors/page.test.tsx | 19 +
app/(root)/page.tsx | 4 +-
jest.config.js | 13 +
jest.setup.js | 1 +
package-lock.json | 7746 ++++++++++++++++++++++------
package.json | 11 +-
tsconfig.json | 1 +
8 files changed, 6187 insertions(+), 1645 deletions(-)
create mode 100644 app/(root)/__tests__/Home.test.tsx
create mode 100644 app/(root)/investors/page.test.tsx
create mode 100644 jest.config.js
create mode 100644 jest.setup.js
diff --git a/app/(root)/__tests__/Home.test.tsx b/app/(root)/__tests__/Home.test.tsx
new file mode 100644
index 0000000..3f5e5df
--- /dev/null
+++ b/app/(root)/__tests__/Home.test.tsx
@@ -0,0 +1,37 @@
+import { fireEvent, render, screen } from '@testing-library/react'
+import Home from '../page';
+
+
+describe('Landing Page: has Explore Button', () => {
+ test('should render with label "Explore the Ecosystem"', () => {
+
+ render();
+
+ const buttonElement = screen.getByRole('button', {name: "Explore the Ecosystem"});
+ expect(buttonElement).toBeInTheDocument()
+ expect(buttonElement.textContent).toEqual("Explore the Ecosystem");
+
+ });
+ test('should be clickable', () => {
+
+ render();
+
+ const buttonElement = screen.getByRole('button', {name: "Explore the Ecosystem"});
+ fireEvent.click(buttonElement);
+ });
+
+ })
+
+describe('Landing Page has link to documentation', () => {
+ test('should render with label "View docs"', () => {
+
+ render();
+
+ const docsLinkElement = screen.getByRole('link');
+ expect(docsLinkElement).toHaveTextContent('View docs');
+
+
+ });
+
+ // todo: add test for checking the link
+ })
\ No newline at end of file
diff --git a/app/(root)/investors/page.test.tsx b/app/(root)/investors/page.test.tsx
new file mode 100644
index 0000000..515067c
--- /dev/null
+++ b/app/(root)/investors/page.test.tsx
@@ -0,0 +1,19 @@
+import { render, screen } from '@testing-library/react'
+import InstitueInstitutionalInvestorsSection from './page'
+
+describe('Investor Page has Our Mission topic', () => {
+
+ test('should render the "Our Mission" heading', () => {
+ // ARRANGE
+ render()
+
+ //ACT
+ const header = screen.getByRole('heading', {
+ name: 'Our Mission'
+ })
+
+ // ASSERT
+ expect(header).toBeInTheDocument()
+ })
+
+})
diff --git a/app/(root)/page.tsx b/app/(root)/page.tsx
index ce1fff9..065910f 100644
--- a/app/(root)/page.tsx
+++ b/app/(root)/page.tsx
@@ -176,10 +176,10 @@ export default function Home() {
Build, deploy, and scale your applications with our powerful infrastructure.
-
Explore the Ecosystem
+
Explore the Ecosystem
-
+
View docs