Skip to content

Commit 1a49291

Browse files
test(feature-cards): add accessibility coverage
1 parent 81d9f71 commit 1a49291

1 file changed

Lines changed: 105 additions & 0 deletions

File tree

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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 Accessibility', () => {
34+
it('renders the primary section heading', () => {
35+
render(
36+
<FeatureCardsSection>
37+
<div>Content</div>
38+
</FeatureCardsSection>
39+
);
40+
41+
expect(
42+
screen.getByRole('heading', {
43+
name: /why commitpulse/i,
44+
})
45+
).toBeInTheDocument();
46+
});
47+
48+
it('renders child content in an accessible document structure', () => {
49+
render(
50+
<FeatureCardsSection>
51+
<button>Accessible Button</button>
52+
</FeatureCardsSection>
53+
);
54+
55+
expect(
56+
screen.getByRole('button', {
57+
name: 'Accessible Button',
58+
})
59+
).toBeInTheDocument();
60+
});
61+
62+
it('preserves keyboard-focusable interactive elements', () => {
63+
render(
64+
<FeatureCardsSection>
65+
<button>Focusable Element</button>
66+
</FeatureCardsSection>
67+
);
68+
69+
const button = screen.getByRole('button', {
70+
name: 'Focusable Element',
71+
});
72+
73+
expect(button).toBeInTheDocument();
74+
});
75+
76+
it('renders descriptive content for screen readers', () => {
77+
render(
78+
<FeatureCardsSection>
79+
<p>Accessibility Description</p>
80+
</FeatureCardsSection>
81+
);
82+
83+
expect(screen.getByText('Accessibility Description')).toBeInTheDocument();
84+
});
85+
86+
it('maintains logical heading hierarchy', () => {
87+
render(
88+
<FeatureCardsSection>
89+
<h2>Secondary Heading</h2>
90+
</FeatureCardsSection>
91+
);
92+
93+
expect(
94+
screen.getByRole('heading', {
95+
name: /why commitpulse/i,
96+
})
97+
).toBeInTheDocument();
98+
99+
expect(
100+
screen.getByRole('heading', {
101+
name: 'Secondary Heading',
102+
})
103+
).toBeInTheDocument();
104+
});
105+
});

0 commit comments

Comments
 (0)