Skip to content

Commit c272f2c

Browse files
committed
created unit tests for FeaturesSection component
1 parent b92ac6a commit c272f2c

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

www/__tests__/Blogs.test.tsx

Whitespace-only changes.

www/__tests__/FeaturesSection.test.tsx

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,42 @@ import {screen, render} from '@testing-library/react';
22
import '@testing-library/jest-dom/extend-expect';
33
import FeaturesSection from '../src/pages/components/FeaturesSection';
44

5-
describe('<FeaturesSection />', () => {
6-
it('renders the core features section', () => {
5+
const features = [
6+
{
7+
name: 'State SnapShot Display',
8+
description: 'See your application state in a stylized and interactive format, for clear concise state management',
9+
},
10+
{
11+
name: 'Time Travel Rendering',
12+
description: 'Simulate any state change from your DOM history, with a simple click of a button',
13+
},
14+
{
15+
name: 'Action Comparison & Snapshot Series',
16+
description: 'Save a series of state snapshots and use it to analyze changes in component render performance between current and previous series of snapshots.',
17+
},
18+
]
19+
20+
describe('FeatureSection component test ', () => {
21+
beforeEach(() => {
722
render(<FeaturesSection />)
23+
});
24+
25+
it('Renders the core features section', () => {
26+
expect(screen.getByText(/Core Features/i)).toBeInTheDocument();
27+
});
28+
29+
it('Title appears on the page', () => {
30+
expect(screen.getByText(/What makes Reactime so great\?/i)).toBeInTheDocument();
31+
});
32+
33+
it('Subheading shows up on the page', () => {
34+
expect(screen.getByText(/Reactime is full of features that make your life easier as a developer. From time-travel debugging to state snapshot display, check out how using Reactime will improve your developer experience./i)).toBeInTheDocument();
35+
})
36+
37+
it('Renders all feature name and descriptions', () => {
38+
features.forEach((feature) => {
39+
expect(screen.getByText(feature.name)).toBeInTheDocument();
40+
expect(screen.getByText(feature.description)).toBeInTheDocument();
41+
});
842
})
943
});

www/src/pages/secret.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const secret: NextPage = () => {
3838
</input>
3939
<button onClick={clickHandler} className="blockrounded-md border rounded border-transparent bg-rose-500 px-5 py-3 text-base font-medium text-white shadow hover:bg-rose-600 focus:outline-none focus:ring-2 focus:ring-rose-500 focus:ring-offset-2 sm:px-10">Submit</button>
4040
</div>}
41-
{isAdmin && <div>{users?.map(user => <div>{user.email}</div>)}</div>}
41+
{isAdmin && <div>{users?.map(user => <span key={user.id}>{user.email}, </span>)}</div>}
4242

4343
</>
4444
);

0 commit comments

Comments
 (0)