|
| 1 | +import { render } from '@testing-library/react'; |
| 2 | +import { describe, expect, it } from 'vitest'; |
| 3 | + |
| 4 | +import { CommitPulseLogo } from './commitpulse-logo'; |
| 5 | + |
| 6 | +describe('CommitPulseLogo accessibility', () => { |
| 7 | + it('renders the SVG logo correctly', () => { |
| 8 | + const { container } = render(<CommitPulseLogo />); |
| 9 | + |
| 10 | + const svg = container.querySelector('svg'); |
| 11 | + |
| 12 | + expect(svg).toBeTruthy(); |
| 13 | + }); |
| 14 | + |
| 15 | + it('marks the SVG as aria-hidden for screen readers', () => { |
| 16 | + const { container } = render(<CommitPulseLogo />); |
| 17 | + |
| 18 | + const svg = container.querySelector('svg'); |
| 19 | + |
| 20 | + expect(svg?.getAttribute('aria-hidden')).toBe('true'); |
| 21 | + }); |
| 22 | + |
| 23 | + it('applies custom class names correctly', () => { |
| 24 | + const { container } = render(<CommitPulseLogo className="h-10 w-10 text-cyan-400" />); |
| 25 | + |
| 26 | + const svg = container.querySelector('svg'); |
| 27 | + |
| 28 | + expect(svg?.getAttribute('class')).toContain('h-10'); |
| 29 | + expect(svg?.getAttribute('class')).toContain('w-10'); |
| 30 | + expect(svg?.getAttribute('class')).toContain('text-cyan-400'); |
| 31 | + }); |
| 32 | + |
| 33 | + it('renders SVG paths for logo structure', () => { |
| 34 | + const { container } = render(<CommitPulseLogo />); |
| 35 | + |
| 36 | + const paths = container.querySelectorAll('path'); |
| 37 | + |
| 38 | + expect(paths.length).toBe(4); |
| 39 | + }); |
| 40 | + |
| 41 | + it('uses accessibility-safe SVG presentation attributes', () => { |
| 42 | + const { container } = render(<CommitPulseLogo />); |
| 43 | + |
| 44 | + const svg = container.querySelector('svg'); |
| 45 | + |
| 46 | + expect(svg?.getAttribute('fill')).toBe('none'); |
| 47 | + expect(svg?.getAttribute('stroke')).toBe('currentColor'); |
| 48 | + }); |
| 49 | +}); |
0 commit comments