-
Notifications
You must be signed in to change notification settings - Fork 864
Expand file tree
/
Copy pathprogressbar.test.tsx
More file actions
59 lines (49 loc) · 2.07 KB
/
progressbar.test.tsx
File metadata and controls
59 lines (49 loc) · 2.07 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
56
57
58
59
/*
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';
import { ProgressBar } from '..';
describe('Stateless progress bar', function () {
it('should render component', () => {
const { container } = render(<ProgressBar value={75} />);
getByRole(container, 'progressbar');
});
it('should render label', () => {
const label = 'label';
const { container } = render(
<ProgressBar value={75} getProgressLabel={() => label} showLabel />
);
getByText(container, label);
});
it('should have step aria-label', () => {
const { container } = render(<ProgressBar value={75} steps={4} />);
getByRole(container, 'progressbar', { name: 'Step 3 of 4' });
});
it('should have loading aria-label if indeterminate', () => {
const { container } = render(<ProgressBar infinite steps={3} />);
getByRole(container, 'progressbar', { name: 'Loading' });
});
it('should have passed in aria-label', () => {
const { container } = render(<ProgressBar aria-label="test" steps={2} />);
getByRole(container, 'progressbar', { name: 'test' });
});
it('should have aria-live attribute for accessibility', () => {
const { container } = render(<ProgressBar value={75} />);
const progressBar = getByRole(container, 'progressbar');
expect(progressBar).toHaveAttribute('aria-live', 'polite');
});
it('should have aria-busy true for infinite progress bar', () => {
const { container } = render(<ProgressBar infinite />);
const progressBar = getByRole(container, 'progressbar');
expect(progressBar).toHaveAttribute('aria-busy', 'true');
});
it('should not have aria-busy for determinate progress bar', () => {
const { container } = render(<ProgressBar value={75} />);
const progressBar = getByRole(container, 'progressbar');
expect(progressBar).not.toHaveAttribute('aria-busy');
});
});