-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathSegmentedProgressBar.test.tsx
More file actions
51 lines (44 loc) · 1.71 KB
/
SegmentedProgressBar.test.tsx
File metadata and controls
51 lines (44 loc) · 1.71 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
// Third party dependencies.
import React from 'react';
import { render } from '@testing-library/react-native';
// Internal dependencies.
import SegmentedProgressBar from './SegmentedProgressBar';
describe('SegmentedProgressBar', () => {
it('renders the outer track with the provided testID', () => {
const { getByTestId } = render(
<SegmentedProgressBar current={1} total={3} testID="progress" />,
);
expect(getByTestId('progress')).toBeOnTheScreen();
});
it('renders the correct number of segment children for a given total', () => {
const total = 4;
const { getByTestId } = render(
<SegmentedProgressBar current={1} total={total} testID="progress" />,
);
expect(getByTestId('progress').children).toHaveLength(total);
});
it('renders no segments when total is 0', () => {
const { getByTestId } = render(
<SegmentedProgressBar current={0} total={0} testID="progress" />,
);
expect(getByTestId('progress').children).toHaveLength(0);
});
it('renders all segments when current is 0', () => {
const total = 3;
const { getByTestId } = render(
<SegmentedProgressBar current={0} total={total} testID="progress" />,
);
expect(getByTestId('progress').children).toHaveLength(total);
});
it('renders all segments when current equals total', () => {
const total = 3;
const { getByTestId } = render(
<SegmentedProgressBar current={total} total={total} testID="progress" />,
);
expect(getByTestId('progress').children).toHaveLength(total);
});
it('renders without a testID when testID prop is omitted', () => {
const { toJSON } = render(<SegmentedProgressBar current={1} total={2} />);
expect(toJSON()).not.toBeNull();
});
});