Skip to content

Commit c8aac38

Browse files
test(feature-cards): add theme contrast coverage
1 parent 81d9f71 commit c8aac38

1 file changed

Lines changed: 96 additions & 0 deletions

File tree

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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 Theme Contrast', () => {
34+
it('renders correctly in simulated light theme', () => {
35+
document.documentElement.classList.remove('dark');
36+
37+
render(
38+
<FeatureCardsSection>
39+
<div>Light Theme Content</div>
40+
</FeatureCardsSection>
41+
);
42+
43+
expect(screen.getByText('Light Theme Content')).toBeInTheDocument();
44+
});
45+
46+
it('renders correctly in simulated dark theme', () => {
47+
document.documentElement.classList.add('dark');
48+
49+
render(
50+
<FeatureCardsSection>
51+
<div>Dark Theme Content</div>
52+
</FeatureCardsSection>
53+
);
54+
55+
expect(screen.getByText('Dark Theme Content')).toBeInTheDocument();
56+
});
57+
58+
it('maintains heading visibility across themes', () => {
59+
render(
60+
<FeatureCardsSection>
61+
<div>Theme Test</div>
62+
</FeatureCardsSection>
63+
);
64+
65+
expect(
66+
screen.getByRole('heading', {
67+
name: /why commitpulse/i,
68+
})
69+
).toBeInTheDocument();
70+
});
71+
72+
it('renders child content without clipping foreground elements', () => {
73+
render(
74+
<FeatureCardsSection>
75+
<button>Foreground Action</button>
76+
</FeatureCardsSection>
77+
);
78+
79+
expect(
80+
screen.getByRole('button', {
81+
name: 'Foreground Action',
82+
})
83+
).toBeInTheDocument();
84+
});
85+
86+
it('preserves layout structure under theme changes', () => {
87+
const { container } = render(
88+
<FeatureCardsSection>
89+
<div>Theme Layout Content</div>
90+
</FeatureCardsSection>
91+
);
92+
93+
expect(container.firstChild).toBeTruthy();
94+
expect(screen.getByText('Theme Layout Content')).toBeInTheDocument();
95+
});
96+
});

0 commit comments

Comments
 (0)