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 2f4ad5f
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 result0_1GB = bytesAsGB(100 * 1024 * 1024);

Check warning on line 15 in frontend/src/utilities/__tests__/number.spec.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Identifier 'result0_1GB' is not in camel case
expect(result0_1GB).toBe(0.1);
});
});

0 comments on commit 2f4ad5f

Please sign in to comment.