Skip to content

Commit 3c9bdd6

Browse files
authored
merge: test(CustomizeCTA): add responsive breakpoint test coverage (#8086)
## Description Fixes #6824 Added a new responsive breakpoint test suite for the `CustomizeCTA` component. The test suite verifies: - Responsive flex layout classes - Responsive heading typography - CTA link accessibility - Responsive spacing utilities - Successful rendering ## 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 change) ## 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 lint` locally. - [x] My commits follow the Conventional Commits format. - [ ] I have updated `README.md` if required. - [x] I have starred the repository. - [x] I have made sure I have only one commit in this PR. - [x] The change only adds test coverage. - [x] I joined the CommitPulse Discord community.
2 parents e03c5cd + cdbb528 commit 3c9bdd6

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { render, screen } from '@testing-library/react';
2+
import { describe, expect, it, vi } from 'vitest';
3+
import '@testing-library/jest-dom/vitest';
4+
5+
import { CustomizeCTA } from './CustomizeCTA';
6+
7+
vi.mock('next/link', () => ({
8+
default: ({ href, children, ...props }: { href: string; children: React.ReactNode }) => (
9+
<a href={href} {...props}>
10+
{children}
11+
</a>
12+
),
13+
}));
14+
15+
vi.mock('@/context/TranslationContext', () => ({
16+
useTranslation: () => ({
17+
t: (key: string) => key,
18+
}),
19+
}));
20+
21+
vi.mock('framer-motion', () => ({
22+
motion: {
23+
div: ({ children, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
24+
<div {...props}>{children}</div>
25+
),
26+
},
27+
}));
28+
29+
describe('CustomizeCTA responsive breakpoints', () => {
30+
it('renders successfully', () => {
31+
render(<CustomizeCTA />);
32+
33+
expect(screen.getByRole('heading', { level: 2 })).toBeInTheDocument();
34+
});
35+
36+
it('uses responsive flex layout classes', () => {
37+
const { container } = render(<CustomizeCTA />);
38+
39+
expect(container.querySelector('.flex-col')).toBeInTheDocument();
40+
expect(container.querySelector('.md\\:flex-row')).toBeInTheDocument();
41+
});
42+
43+
it('uses responsive heading typography', () => {
44+
render(<CustomizeCTA />);
45+
46+
const heading = screen.getByRole('heading', { level: 2 });
47+
48+
expect(heading).toHaveClass('text-2xl');
49+
expect(heading).toHaveClass('md:text-3xl');
50+
});
51+
52+
it('keeps CTA link accessible on all layouts', () => {
53+
render(<CustomizeCTA />);
54+
55+
expect(
56+
screen.getByRole('link', {
57+
name: /customize_cta\.btn/i,
58+
})
59+
).toHaveAttribute('href', '/customize');
60+
});
61+
62+
it('applies responsive spacing utilities', () => {
63+
const { container } = render(<CustomizeCTA />);
64+
65+
expect(container.querySelector('.gap-8')).toBeInTheDocument();
66+
expect(container.querySelector('.px-8')).toBeInTheDocument();
67+
expect(container.querySelector('.py-10')).toBeInTheDocument();
68+
});
69+
});

0 commit comments

Comments
 (0)