|
| 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