fix(filesystem): handle negative values in formatSize() (#3231)
Return '0 B' for negative byte values instead of 'NaN B'. File sizes cannot be negative, so this is a safe default. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
599dafc105
commit
8102fbe27a
1 changed files with 5 additions and 3 deletions
|
|
@ -65,8 +65,10 @@ describe('Lib Functions', () => {
|
|||
});
|
||||
|
||||
it('handles negative numbers', () => {
|
||||
// Negative numbers will result in NaN for the log calculation
|
||||
expect(formatSize(-1024)).toContain('NaN');
|
||||
// Negative numbers should return '0 B' as file sizes cannot be negative
|
||||
expect(formatSize(-1)).toBe('0 B');
|
||||
expect(formatSize(-1024)).toBe('0 B');
|
||||
expect(formatSize(-1000000)).toBe('0 B');
|
||||
expect(formatSize(-0)).toBe('0 B');
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue