Skip to content

Commit 62ff69f

Browse files
committed
test(ui): cover Progress custom format
1 parent 28d5508 commit 62ff69f

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

packages/ui/src/components/data/Progress/Progress.test.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,31 @@ describe('Progress', () => {
2525
expect(screen.getByText('100%')).toBeInTheDocument()
2626
})
2727

28+
it('uses custom formatted text for visible and accessible value text', () => {
29+
render(<Progress percent={75} format={(value) => `${value} days`} />)
30+
31+
const progress = screen.getByRole('progressbar', { name: 'Progress' })
32+
33+
expect(progress).toHaveAttribute('aria-valuenow', '75')
34+
expect(progress).toHaveAttribute('aria-valuetext', '75 days')
35+
expect(screen.getByText('75 days')).toBeInTheDocument()
36+
})
37+
38+
it('keeps explicit value text when custom formatted content is visual only', () => {
39+
render(
40+
<Progress
41+
percent={75}
42+
format={(value) => <span>{value} days</span>}
43+
aria-valuetext="75 days remaining"
44+
/>,
45+
)
46+
47+
const progress = screen.getByRole('progressbar', { name: 'Progress' })
48+
49+
expect(progress).toHaveAttribute('aria-valuetext', '75 days remaining')
50+
expect(screen.getByText('75 days')).toBeInTheDocument()
51+
})
52+
2853
it('supports external labelling and custom value text', () => {
2954
render(
3055
<div>
@@ -44,4 +69,4 @@ describe('Progress', () => {
4469
expect(progress).toHaveAttribute('aria-valuetext', '64 percent complete')
4570
expect(screen.queryByText('64%')).not.toBeInTheDocument()
4671
})
47-
})
72+
})

0 commit comments

Comments
 (0)