Migrate paths dashboard widget to react and add storage metrics

This commit is contained in:
Bill Thornton
2025-06-03 16:28:22 -04:00
parent a938650ded
commit 09063d3376
11 changed files with 322 additions and 81 deletions
+22
View File
@@ -0,0 +1,22 @@
import { describe, expect, it } from 'vitest';
import { getReadableSize } from './file';
describe('getReadableSize()', () => {
it('should return the correct units', () => {
expect(getReadableSize(5)).toBe('5.0 Bytes');
expect(getReadableSize(1024)).toBe('1.0 KiB');
expect(getReadableSize(1024 * 1024)).toBe('1.0 MiB');
expect(getReadableSize(1024 * 1024 * 1024)).toBe('1.0 GiB');
expect(getReadableSize(1024 * 1024 * 1024 * 1024)).toBe('1.0 TiB');
expect(getReadableSize(1024 * 1024 * 1024 * 1024 * 1024)).toBe('1.0 PiB');
expect(getReadableSize(1024 * 1024 * 1024 * 1024 * 1024 * 1024)).toBe('1.0 EiB');
expect(getReadableSize(1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024)).toBe('1.0 ZiB');
expect(getReadableSize(1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024)).toBe('1.0 YiB');
});
it('should return the correct precision', () => {
expect(getReadableSize(12345, 0)).toBe('12 KiB');
expect(getReadableSize(12345, 2)).toBe('12.06 KiB');
expect(getReadableSize(12345, 3)).toBe('12.056 KiB');
});
});