|
| 1 | +import { render } from '@testing-library/react'; |
| 2 | +import { describe, expect, it } from 'vitest'; |
| 3 | + |
| 4 | +import { BoxIcon, CheckIcon, CloseIcon, CopyIcon, ZapIcon } from './Icons'; |
| 5 | + |
| 6 | +describe('Icons accessibility behavior', () => { |
| 7 | + it('renders CopyIcon as decorative with aria-hidden="true"', () => { |
| 8 | + const { container } = render(<CopyIcon />); |
| 9 | + const svg = container.querySelector('svg'); |
| 10 | + expect(svg?.getAttribute('aria-hidden')).toBe('true'); |
| 11 | + }); |
| 12 | + |
| 13 | + it('renders ZapIcon as decorative with aria-hidden="true"', () => { |
| 14 | + const { container } = render(<ZapIcon />); |
| 15 | + const svg = container.querySelector('svg'); |
| 16 | + expect(svg?.getAttribute('aria-hidden')).toBe('true'); |
| 17 | + }); |
| 18 | + |
| 19 | + it('renders BoxIcon as decorative with aria-hidden="true"', () => { |
| 20 | + const { container } = render(<BoxIcon />); |
| 21 | + const svg = container.querySelector('svg'); |
| 22 | + expect(svg?.getAttribute('aria-hidden')).toBe('true'); |
| 23 | + }); |
| 24 | + |
| 25 | + it('renders CheckIcon as decorative with aria-hidden="true"', () => { |
| 26 | + const { container } = render(<CheckIcon />); |
| 27 | + const svg = container.querySelector('svg'); |
| 28 | + expect(svg?.getAttribute('aria-hidden')).toBe('true'); |
| 29 | + }); |
| 30 | + |
| 31 | + it('renders CloseIcon as decorative with aria-hidden="true"', () => { |
| 32 | + const { container } = render(<CloseIcon />); |
| 33 | + const svg = container.querySelector('svg'); |
| 34 | + expect(svg?.getAttribute('aria-hidden')).toBe('true'); |
| 35 | + }); |
| 36 | + |
| 37 | + it('includes basic structural roles on SVG elements', () => { |
| 38 | + const { container } = render(<CopyIcon />); |
| 39 | + const svg = container.querySelector('svg'); |
| 40 | + // Lucide components use standard svg elements which imply a graphics role, |
| 41 | + // and setting aria-hidden="true" makes it decorative. |
| 42 | + expect(svg?.tagName.toLowerCase()).toBe('svg'); |
| 43 | + }); |
| 44 | +}); |
0 commit comments