Skip to content

Commit

Permalink
Unit Test Case for bytesAsGB (number.ts)
Browse files Browse the repository at this point in the history
  • Loading branch information
uidoyen committed Jan 17, 2024
1 parent cb3be2d commit e40c91e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions frontend/src/utilities/__tests__/number.spec.ts
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);
});
});

0 comments on commit e40c91e

Please sign in to comment.