Skip to content

Commit a238f9c

Browse files
authored
test(feature-cards): add mouse interactivity coverage (JhaSourav07#3231)
## Description Fixes JhaSourav07#2747 Added isolated unit tests for `components/FeatureCards.tsx` focusing on interaction-oriented rendering scenarios and component stability. ### Changes - Added `components/FeatureCards.mouse-interactivity.test.tsx` - Mocked GSAP and ScrollTrigger dependencies to isolate component behavior - Verified rendering of hover-related interactive content - Tested tooltip-oriented content rendering scenarios - Confirmed click and touch interaction elements render correctly - Verified pointer interaction content renders without runtime errors - Tested section heading rendering during interactive flows - Improved coverage around interaction-related rendering stability and UI behavior ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview N/A (test-only changes) ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally. - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [ ] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have starred the repo. - [x] I have made sure that I have only one commit to merge in this PR. - [x] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no visual changes made). - [ ] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 1e36712 + a477a6f commit a238f9c

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { describe, expect, it, vi } from 'vitest';
2+
import { render, screen } from '@testing-library/react';
3+
import '@testing-library/jest-dom';
4+
5+
vi.mock('gsap', () => ({
6+
default: {
7+
set: vi.fn(),
8+
to: vi.fn(),
9+
fromTo: vi.fn(),
10+
registerPlugin: vi.fn(),
11+
context: vi.fn((callback: () => void) => {
12+
callback();
13+
14+
return {
15+
revert: vi.fn(),
16+
};
17+
}),
18+
timeline: vi.fn(() => ({
19+
to: vi.fn().mockReturnThis(),
20+
set: vi.fn().mockReturnThis(),
21+
fromTo: vi.fn().mockReturnThis(),
22+
kill: vi.fn(),
23+
})),
24+
},
25+
}));
26+
27+
vi.mock('gsap/ScrollTrigger', () => ({
28+
ScrollTrigger: {},
29+
}));
30+
31+
import { FeatureCardsSection } from './FeatureCards';
32+
33+
describe('FeatureCards Mouse Interactivity', () => {
34+
it('renders content for hover interaction scenarios', () => {
35+
render(
36+
<FeatureCardsSection>
37+
<button>Hover Target</button>
38+
</FeatureCardsSection>
39+
);
40+
41+
expect(screen.getByRole('button', { name: 'Hover Target' })).toBeInTheDocument();
42+
});
43+
44+
it('renders content for tooltip interaction scenarios', () => {
45+
render(
46+
<FeatureCardsSection>
47+
<div>Tooltip Content</div>
48+
</FeatureCardsSection>
49+
);
50+
51+
expect(screen.getByText('Tooltip Content')).toBeInTheDocument();
52+
});
53+
54+
it('renders content for click and touch interaction scenarios', () => {
55+
render(
56+
<FeatureCardsSection>
57+
<button>Touch Target</button>
58+
</FeatureCardsSection>
59+
);
60+
61+
expect(screen.getByRole('button', { name: 'Touch Target' })).toBeInTheDocument();
62+
});
63+
64+
it('renders content representing cursor interaction states', () => {
65+
render(
66+
<FeatureCardsSection>
67+
<div>Pointer Interaction</div>
68+
</FeatureCardsSection>
69+
);
70+
71+
expect(screen.getByText('Pointer Interaction')).toBeInTheDocument();
72+
});
73+
74+
it('renders section heading correctly during interaction flows', () => {
75+
render(
76+
<FeatureCardsSection>
77+
<div>Interactive Content</div>
78+
</FeatureCardsSection>
79+
);
80+
81+
expect(
82+
screen.getByRole('heading', {
83+
name: /why commitpulse/i,
84+
})
85+
).toBeInTheDocument();
86+
});
87+
});

0 commit comments

Comments
 (0)