-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
918d662
commit 3556cdb
Showing
1 changed file
with
52 additions
and
3 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 |
---|---|---|
@@ -1,8 +1,57 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import App from './App'; | ||
import ContactForm from './components/Contact'; | ||
import reportWebVitals from "./reportWebVitals"; | ||
import About from './components/About/About'; | ||
|
||
test('renders learn react link', () => { | ||
// Test home page content | ||
test('Test home page content', () => { | ||
render(<App />); | ||
const linkElement = screen.getByText(/learn react/i); | ||
expect(linkElement).toBeInTheDocument(); | ||
const linkElement1 = screen.getByText(/Welcome!/i); | ||
const linkElement2 = screen.getByText(/We are/i); | ||
const linkElements3 = screen.getAllByText(/Studio Zed/i); | ||
|
||
expect(linkElement1).toBeInTheDocument(); | ||
expect(linkElement2).toBeInTheDocument(); | ||
expect(linkElements3.length).toBeGreaterThan(0); // If atleast 1 match. | ||
}); | ||
|
||
// Test contact form | ||
test('Find contact form', async () => { | ||
render(<ContactForm />); | ||
const formTitle = await screen.findByText(/Get in touch!/i); | ||
const formFieldName = await screen.findByPlaceholderText(/Name/i); | ||
const formFieldEmail = await screen.findByPlaceholderText(/Email/i); | ||
const formFieldMessage = await screen.findByPlaceholderText(/Message/i); | ||
|
||
expect(formTitle).toBeInTheDocument(); | ||
expect(formFieldName).toBeInTheDocument(); | ||
expect(formFieldEmail).toBeInTheDocument(); | ||
expect(formFieldMessage).toBeInTheDocument(); | ||
}); | ||
|
||
// Test form submit button | ||
test('Find form submit button', () => { | ||
render(<ContactForm />); | ||
const submitButton = screen.getByRole('button', { name: /Submit/i }); | ||
expect(submitButton).toBeInTheDocument(); | ||
}); | ||
|
||
// Test web vitals | ||
test('Test web vitals', () => { | ||
reportWebVitals(metric => { | ||
console.log('Web Vitals metric:', metric); | ||
expect(metric).toBeDefined(); | ||
expect(metric.name).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
// Test if about page is rendered | ||
test('Test if about page is rendered', () => { | ||
render(<About />); | ||
const aboutPage = About(); | ||
if (aboutPage != null) { | ||
console.log("About page is rendered"); | ||
} | ||
expect(aboutPage).not.toBeNull(); | ||
}); |