Skip to content

Commit 46a9f7a

Browse files
Merge pull request #1644 from hackforla/progress-bar-tests-1246
fixes #1246 progress bar testing
2 parents af4b3f9 + 6f9aeb5 commit 46a9f7a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
import { render, screen } from '@testing-library/react';
3+
import '@testing-library/jest-dom';
4+
import ProgressBar from 'components/ProgressBar';
5+
6+
describe('Progress Bar', () => {
7+
// tests that progress bar renders correctly
8+
test('renders the progress bar component', () => {
9+
render(<ProgressBar percentage={16.67} />);
10+
const progressBarElement = screen.getByRole('progressbar');
11+
expect(progressBarElement).toBeInTheDocument();
12+
});
13+
14+
// tests that progress bar renders the percentage that it's passed
15+
test('progress bar displays the correct percentage', () => {
16+
render(<ProgressBar percentage={50} />);
17+
const progressBarElement = screen.getByRole('progressbar');
18+
expect(progressBarElement).toHaveAttribute('aria-valuenow', '50');
19+
});
20+
21+
// tests that progress bar renders the percentage its passed when completed
22+
test('progress bar displays the correct max percentage', () => {
23+
render(<ProgressBar percentage={100} />);
24+
const progressBarElement = screen.getByRole('progressbar');
25+
expect(progressBarElement).toHaveAttribute('aria-valuenow', '100');
26+
});
27+
});

0 commit comments

Comments
 (0)