-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit tests with Jest and React testing (#53)
- Loading branch information
Showing
8 changed files
with
6,187 additions
and
1,645 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(<Home />); | ||
|
||
const buttonElement = screen.getByRole('button', {name: "Explore the Ecosystem"}); | ||
expect(buttonElement).toBeInTheDocument() | ||
expect(buttonElement.textContent).toEqual("Explore the Ecosystem"); | ||
|
||
}); | ||
test('should be clickable', () => { | ||
|
||
render(<Home />); | ||
|
||
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(<Home />); | ||
|
||
const docsLinkElement = screen.getByRole('link'); | ||
expect(docsLinkElement).toHaveTextContent('View docs'); | ||
|
||
|
||
}); | ||
|
||
// todo: add test for checking the link | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(<InstitueInstitutionalInvestorsSection />) | ||
|
||
//ACT | ||
const header = screen.getByRole('heading', { | ||
name: 'Our Mission' | ||
}) | ||
|
||
// ASSERT | ||
expect(header).toBeInTheDocument() | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const nextJest = require("next/jest"); | ||
|
||
const createJestConfig = nextJest({ | ||
dir: "./", | ||
}); | ||
|
||
const customJestConfig = { | ||
setupFilesAfterEnv: ["./jest.setup.js"], | ||
testEnvironment: "jest-environment-jsdom", | ||
preset: 'ts-jest' | ||
}; | ||
|
||
module.exports = createJestConfig(customJestConfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "@testing-library/jest-dom"; |
Oops, something went wrong.