-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
100 additions
and
22 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
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
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
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
48 changes: 48 additions & 0 deletions
48
packages/utils/src/lib/collect/implementation/utils.spec.ts
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,48 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { formatBytes } from './utils'; | ||
|
||
describe('formatBytes', () => { | ||
it('should log file sizes in Bytes`', async () => { | ||
expect(formatBytes(1000)).toBe('1000 Bytes'); | ||
}); | ||
|
||
it('should log file sizes in KB`', async () => { | ||
expect(formatBytes(10000)).toBe('9.77 KB'); | ||
}); | ||
|
||
it('should log file sizes in MB`', async () => { | ||
expect(formatBytes(10000000)).toBe('9.54 MB'); | ||
}); | ||
|
||
it('should log file sizes in bytes`', async () => { | ||
expect(formatBytes(10000000000)).toBe('9.31 GB'); | ||
}); | ||
|
||
it('should log file sizes in TB`', async () => { | ||
expect(formatBytes(10000000000000)).toBe('9.09 TB'); | ||
}); | ||
|
||
it('should log file sizes in PB`', async () => { | ||
expect(formatBytes(10000000000000000)).toBe('8.88 PB'); | ||
}); | ||
|
||
it('should log file sizes in EB`', async () => { | ||
expect(formatBytes(10000000000000000000)).toBe('8.67 EB'); | ||
}); | ||
|
||
it('should log file sizes in ZB`', async () => { | ||
expect(formatBytes(10000000000000000000000)).toBe('8.47 ZB'); | ||
}); | ||
|
||
it('should log file sizes in YB`', async () => { | ||
expect(formatBytes(10000000000000000000000000)).toBe('8.27 YB'); | ||
}); | ||
|
||
it('should log file sizes correctly with correct decimal`', async () => { | ||
expect(formatBytes(10000, 1)).toBe('9.8 KB'); | ||
}); | ||
|
||
it('should log file sizes of 0 if no size is given`', async () => { | ||
expect(formatBytes(0)).toBe('0 Bytes'); | ||
}); | ||
}); |
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