Skip to content

Commit bedfbda

Browse files
committed
Add unit tests for number format util functions
1 parent d391162 commit bedfbda

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { bytesToMB, getTotalLabel } from '.'
2+
3+
describe('bytesToMB', () => {
4+
test('will convert bytes to MB', () => {
5+
const sizeBytes = 1024 * 1024 * 30
6+
const sizeMB = 30
7+
const result = bytesToMB(sizeBytes)
8+
expect(result).toEqual(sizeMB)
9+
})
10+
})
11+
12+
describe('getTotalLabel', () => {
13+
test(`will show the sample length followed by a '+' if the known total is more than the sample length`, () => {
14+
const result = getTotalLabel(10, 100)
15+
expect(result).toEqual('10+')
16+
})
17+
18+
test('will show the sample length if the known total is equal to the sample length', () => {
19+
const result = getTotalLabel(10, 10)
20+
expect(result).toEqual('10')
21+
})
22+
})

0 commit comments

Comments
 (0)