|
1 | 1 | import React from 'react'; |
2 | 2 | import { render } from '@testing-library/react'; |
3 | | -import { Circle, type ProgressProps } from '../src'; |
| 3 | +import { Circle, Line, type ProgressProps } from '../src'; |
4 | 4 |
|
5 | 5 | describe('Semantic', () => { |
| 6 | + it('hides decorative SVGs and supports explicit progress semantics', () => { |
| 7 | + const { container } = render( |
| 8 | + <> |
| 9 | + <Line percent={25} /> |
| 10 | + <Circle |
| 11 | + percent={50} |
| 12 | + role="progressbar" |
| 13 | + aria-label="Upload progress" |
| 14 | + aria-valuemin={0} |
| 15 | + aria-valuemax={100} |
| 16 | + aria-valuenow={50} |
| 17 | + /> |
| 18 | + </>, |
| 19 | + ); |
| 20 | + |
| 21 | + const [line, circle] = container.querySelectorAll('svg'); |
| 22 | + expect(line).toHaveAttribute('role', 'presentation'); |
| 23 | + expect(circle).toHaveAttribute('role', 'progressbar'); |
| 24 | + expect(circle).toHaveAccessibleName('Upload progress'); |
| 25 | + expect(circle).toHaveAttribute('aria-valuemin', '0'); |
| 26 | + expect(circle).toHaveAttribute('aria-valuemax', '100'); |
| 27 | + expect(circle).toHaveAttribute('aria-valuenow', '50'); |
| 28 | + }); |
| 29 | + |
| 30 | + it('supports explicit progress semantics for lines', () => { |
| 31 | + const { container } = render( |
| 32 | + <Line |
| 33 | + id="download-progress" |
| 34 | + percent={25} |
| 35 | + role="progressbar" |
| 36 | + aria-label="Download progress" |
| 37 | + aria-valuemin={0} |
| 38 | + aria-valuemax={100} |
| 39 | + aria-valuenow={25} |
| 40 | + />, |
| 41 | + ); |
| 42 | + |
| 43 | + const line = container.querySelector('svg'); |
| 44 | + expect(line).toHaveAttribute('id', 'download-progress'); |
| 45 | + expect(line).toHaveAttribute('role', 'progressbar'); |
| 46 | + expect(line).toHaveAccessibleName('Download progress'); |
| 47 | + expect(line).toHaveAttribute('aria-valuemin', '0'); |
| 48 | + expect(line).toHaveAttribute('aria-valuemax', '100'); |
| 49 | + expect(line).toHaveAttribute('aria-valuenow', '25'); |
| 50 | + }); |
| 51 | + |
6 | 52 | describe('Circle', () => { |
7 | 53 | function test( |
8 | 54 | name: string, |
|
0 commit comments