teqo/tests/unit/campaignHero.unit.spec.tsx
Francisco Solla 0aec0d5040
Some checks failed
CI / e2e (1) (push) Successful in 11m3s
CI / static (push) Successful in 2m8s
CI / int (push) Successful in 2m15s
CI / build (push) Successful in 2m58s
CI / e2e (2) (push) Successful in 4m41s
CI / checks (push) Successful in 2s
CI / deploy homeserver (teqo-1313) (push) Failing after 5s
feat(PUB5): slogan 'Mais saúde mais futuro' no hero e rodapé
2026-08-18 01:31:28 +00:00

40 lines
1.6 KiB
TypeScript

import { cleanup, render, screen } from '@testing-library/react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { CampaignHero } from '@/components/CampaignHero'
type MockImageProps = React.ImgHTMLAttributes<HTMLImageElement> & { priority?: boolean }
vi.mock('next/image', () => ({
default: ({ alt, priority: _priority, ...props }: MockImageProps) => (
// eslint-disable-next-line @next/next/no-img-element
<img alt={alt} {...props} />
),
}))
afterEach(cleanup)
describe('CampaignHero', () => {
it('apresenta a candidatura e mantém um único CTA primário', () => {
render(<CampaignHero />)
expect(screen.getByRole('heading', { level: 1, name: 'MAIS SAÚDE MAIS FUTURO' })).toBeTruthy()
const supportLink = screen.getByRole('link', { name: /Quero apoiar/i })
expect(supportLink.getAttribute('href')).toBe('https://apoiar.me/jorgesolla')
expect(supportLink.getAttribute('data-cta')).toBe('primary')
const flagsLink = screen.getByRole('link', { name: /Conhecer bandeiras/i })
expect(flagsLink.getAttribute('href')).toBe('#bandeiras')
expect(flagsLink.getAttribute('data-cta')).toBe('secondary')
})
it('expõe as provas e as fotos com nomes acessíveis', () => {
render(<CampaignHero />)
expect(screen.getByLabelText('DIAP entre os 40 melhores da Câmara')).toBeTruthy()
expect(screen.getByLabelText('Mais votado do PT-BA em 2022')).toBeTruthy()
expect(screen.getByRole('img', { name: /Jorge Solla 1313/i })).toBeTruthy()
expect(screen.getByAltText('Jorge Solla, candidato a deputado federal pela Bahia')).toBeTruthy()
})
})