Skip to content

Commit ab318a4

Browse files
test: add HeroSection component test coverage (JhaSourav07#851)
* cleaned * dashboard link disabled * test solved * herosection test * . * herotest
1 parent 1cdbe01 commit ab318a4

3 files changed

Lines changed: 141 additions & 2 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import '@testing-library/jest-dom';
2+
import { render, screen } from '@testing-library/react';
3+
import { describe, expect, it, vi } from 'vitest';
4+
import { HeroSection } from './HeroSection';
5+
6+
vi.mock('framer-motion', () => ({
7+
motion: {
8+
div: 'div',
9+
section: 'section',
10+
h1: 'h1',
11+
p: 'p',
12+
},
13+
}));
14+
15+
describe('HeroSection', () => {
16+
it('renders the h1 heading', () => {
17+
render(<HeroSection />);
18+
19+
const heading = screen.getByRole('heading', {
20+
level: 1,
21+
});
22+
23+
expect(heading).toBeInTheDocument();
24+
});
25+
26+
it("heading contains 'Elevate Your'", () => {
27+
render(<HeroSection />);
28+
29+
expect(screen.getByText(/Elevate Your/i)).toBeInTheDocument();
30+
});
31+
32+
it("heading contains 'Contribution Story'", () => {
33+
render(<HeroSection />);
34+
35+
expect(screen.getByText(/Contribution Story/i)).toBeInTheDocument();
36+
});
37+
38+
it('renders the descriptive paragraph', () => {
39+
render(<HeroSection />);
40+
41+
const paragraph = screen.getByText(/isometric/i);
42+
43+
expect(paragraph).toBeInTheDocument();
44+
});
45+
46+
it("paragraph mentions 'isometric'", () => {
47+
render(<HeroSection />);
48+
49+
expect(screen.getByText(/isometric/i)).toHaveTextContent(/isometric/i);
50+
});
51+
});

package-lock.json

Lines changed: 89 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"devDependencies": {
4040
"@emnapi/core": "^1.10.0",
4141
"@emnapi/runtime": "^1.10.0",
42+
"@testing-library/jest-dom": "^6.9.1",
4243
"@testing-library/react": "^16.3.2",
4344
"@types/node": "^20",
4445
"@types/react": "^19",

0 commit comments

Comments
 (0)