-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathprogress-bar.test.js
More file actions
25 lines (19 loc) · 804 Bytes
/
Copy pathprogress-bar.test.js
File metadata and controls
25 lines (19 loc) · 804 Bytes
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
import { createProgressBar } from './progress-bar';
test('Progress is 0%', () => {
expect(createProgressBar(0)).toEqual('[▱▱▱▱▱▱▱▱▱▱]');
});
test('Progress is 100%', () => {
expect(createProgressBar(1)).toEqual('[▰▰▰▰▰▰▰▰▰▰]');
});
test('Custom character counts', () => {
expect(createProgressBar(0.2, 20)).toEqual('[▰▰▰▰▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱]');
});
test('Percentage rounding', () => {
expect(createProgressBar(0.35)).toEqual('[▰▰▰▰▱▱▱▱▱▱]');
});
test('Greater than 1', () => {
expect(createProgressBar(20)).toEqual('[▰▰▱▱▱▱▱▱▱▱]');
});
test('Works with fixed width spaces', () => {
expect(createProgressBar(0.2, 20, ' ')).toEqual('[▰▰▰▰ ]');
});