Roll back changes to conversion unit (1000->1024)

closes #4183
This commit is contained in:
DaneEveritt 2022-06-27 18:46:36 -04:00
parent 1b5d77dc17
commit 72f545259f
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 29 additions and 21 deletions

View file

@ -3,11 +3,11 @@ import { bytesToString, ip, mbToBytes } from '@/lib/formatters';
describe('@/lib/formatters.ts', function () {
describe('mbToBytes()', function () {
it('should convert from MB to Bytes', function () {
expect(mbToBytes(1)).toBe(1_000_000);
expect(mbToBytes(1)).toBe(1_048_576);
expect(mbToBytes(0)).toBe(0);
expect(mbToBytes(0.1)).toBe(100_000);
expect(mbToBytes(0.001)).toBe(1000);
expect(mbToBytes(1024)).toBe(1_024_000_000);
expect(mbToBytes(0.1)).toBe(104_857);
expect(mbToBytes(0.001)).toBe(1_048);
expect(mbToBytes(1024)).toBe(1_073_741_824);
});
});
@ -20,18 +20,23 @@ describe('@/lib/formatters.ts', function () {
[100.25, '100.25 Bytes'],
[100.998, '101 Bytes'],
[512, '512 Bytes'],
[1000, '1 KB'],
[1024, '1.02 KB'],
[5068, '5.07 KB'],
[10_000, '10 KB'],
[11_864, '11.86 KB'],
[1_000_000, '1 MB'],
[1_356_000, '1.36 MB'],
[1_024_000, '1.02 MB'],
[1_000_000_000, '1 GB'],
[1_024_000_000, '1.02 GB'],
[1_678_342_000, '1.68 GB'],
[1_000_000_000_000, '1 TB'],
[1000, '1000 Bytes'],
[1024, '1 KB'],
[5068, '4.95 KB'],
[10_000, '9.77 KB'],
[10_240, '10 KB'],
[11_864, '11.59 KB'],
[1_000_000, '976.56 KB'],
[1_024_000, '1000 KB'],
[1_025_000, '1000.98 KB'],
[1_048_576, '1 MB'],
[1_356_000, '1.29 MB'],
[1_000_000_000, '953.67 MB'],
[1_070_000_100, '1020.43 MB'],
[1_073_741_824, '1 GB'],
[1_678_342_000, '1.56 GB'],
[1_000_000_000_000, '931.32 GB'],
[1_099_511_627_776, '1 TB'],
])('should format %d bytes as "%s"', function (input, output) {
expect(bytesToString(input)).toBe(output);
});