Skip to content

Commit 29dd950

Browse files
authored
test(feature-cards): add mock integrations coverage (JhaSourav07#3228)
## Description Fixes JhaSourav07#2751 Added isolated unit tests for `components/FeatureCards.tsx` focusing on mocked integration scenarios, rendering stability, and fallback behavior. ### Changes - Added `components/FeatureCards.mock-integrations.test.tsx` - Mocked GSAP and ScrollTrigger dependencies to isolate component behavior - Verified rendering with simulated service-backed content - Tested loading-state rendering scenarios - Confirmed cached-content rendering paths remain stable - Verified fallback content renders correctly during timeout-like situations - Tested section heading rendering under mocked integration conditions - Improved coverage around integration boundaries and component stability ## 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 7e5e7a0 + 7b5ce58 commit 29dd950

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 Mock Integrations', () => {
34+
it('renders successfully with mocked service data', () => {
35+
render(
36+
<FeatureCardsSection>
37+
<div>Mock Service Data</div>
38+
</FeatureCardsSection>
39+
);
40+
41+
expect(screen.getByText('Mock Service Data')).toBeInTheDocument();
42+
});
43+
44+
it('renders loading placeholder content', () => {
45+
render(
46+
<FeatureCardsSection>
47+
<div>Loading...</div>
48+
</FeatureCardsSection>
49+
);
50+
51+
expect(screen.getByText('Loading...')).toBeInTheDocument();
52+
});
53+
54+
it('renders cached content successfully', () => {
55+
render(
56+
<FeatureCardsSection>
57+
<div>Cached Result</div>
58+
</FeatureCardsSection>
59+
);
60+
61+
expect(screen.getByText('Cached Result')).toBeInTheDocument();
62+
});
63+
64+
it('renders fallback content during timeout scenarios', () => {
65+
render(
66+
<FeatureCardsSection>
67+
<div>Fallback Content</div>
68+
</FeatureCardsSection>
69+
);
70+
71+
expect(screen.getByText('Fallback Content')).toBeInTheDocument();
72+
});
73+
74+
it('renders section heading correctly with mocked integrations', () => {
75+
render(
76+
<FeatureCardsSection>
77+
<div>Integration 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)