-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit Test Case for bytesAsGB (number.ts)
- Loading branch information
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { bytesAsGB } from '~/utilities/number'; | ||
|
||
describe('bytesAsGB', () => { | ||
it('should return 0 for NaN input', () => { | ||
const resultNaN = bytesAsGB(NaN); | ||
expect(resultNaN).toBe(0); | ||
}); | ||
|
||
it('should convert bytes to gigabytes and round to 1 decimal place when greater than or equal to 0.1 GB', () => { | ||
const result1GB = bytesAsGB(1024 * 1024 * 1024); | ||
expect(result1GB).toBe(1); | ||
}); | ||
|
||
it('should round to 2 decimal places when less than 0.1 GB', () => { | ||
const result01GB = bytesAsGB(100 * 1024 * 1024); | ||
expect(result01GB).toBe(0.1); | ||
}); | ||
}); |