Skip to content

Commit 7b5ce58

Browse files
test(feature-cards): add mock integrations coverage
1 parent 81d9f71 commit 7b5ce58

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)