-
Notifications
You must be signed in to change notification settings - Fork 864
Expand file tree
/
Copy pathprogressbar-rounded.test.tsx
More file actions
55 lines (46 loc) · 2.23 KB
/
progressbar-rounded.test.tsx
File metadata and controls
55 lines (46 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
Copyright (c) Uber Technologies, Inc.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
import * as React from 'react';
import { render, getByRole, getByText } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import { ProgressBarRounded, SIZE } from '..';
describe('Rounded progress bar', function () {
it('should render component', () => {
const { container } = render(<ProgressBarRounded progress={0.5} size={SIZE.medium} />);
getByRole(container, 'progressbar');
});
it('should render component and displays the progress', async () => {
const { container } = render(<ProgressBarRounded progress={0.5} size={SIZE.medium} />);
getByText(container, '50%');
});
it('should render component and set a correct aria-valuenow value (numeric)', async () => {
const { container } = render(<ProgressBarRounded progress={0.5} size={SIZE.medium} />);
const progressBar = getByRole(container, 'progressbar');
expect(progressBar).toHaveAttribute('aria-valuenow', '0.5');
});
it('should have aria-live attribute for accessibility', () => {
const { container } = render(<ProgressBarRounded progress={0.5} />);
const progressBar = getByRole(container, 'progressbar');
expect(progressBar).toHaveAttribute('aria-live', 'polite');
});
it('should have default aria-label with percentage', () => {
const { container } = render(<ProgressBarRounded progress={0.75} />);
const progressBar = getByRole(container, 'progressbar', { name: '75% complete' });
expect(progressBar).toBeInTheDocument();
});
it('should accept custom aria-label prop', () => {
const { container } = render(<ProgressBarRounded progress={0.5} ariaLabel="Uploading file" />);
const progressBar = getByRole(container, 'progressbar', { name: 'Uploading file' });
expect(progressBar).toBeInTheDocument();
});
it('should accept custom aria-label via kebab-case prop', () => {
const { container } = render(
<ProgressBarRounded progress={0.5} aria-label="Processing data" />
);
const progressBar = getByRole(container, 'progressbar', { name: 'Processing data' });
expect(progressBar).toBeInTheDocument();
});
});