Files
testing-tool/src/utils/__tests__/format.test.ts
T
LingandRX 945780def8 Develop (#55)
feat: optimize dashboard/search UX and simplify extension architecture

Redesign Dashboard with compact tool grid and recently used tools
Improve TopBar search UX with Cmd/Ctrl+K shortcut and better history navigation
Reorganize project structure into src/
Migrate i18n from react-i18next to chrome.i18n
Remove runtime language switch and settings page
Remove HTML/Markdown conversion tools
Clean up unused code, dead animations, redundant comments, and imports
Improve component consistency with shadcn/ui patterns
Replace hardcoded strings/colors with i18n tokens and theme tokens
Add comprehensive project documentation and coding standards
Fix CI artifact upload workflow and multiple TypeScript/test issues

Includes various refactors, UI polish, i18n cleanup, CI improvements,
and maintenance updates across the codebase.
2026-05-28 22:39:25 +08:00

45 lines
1.3 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { formatBytes } from '@/utils/format';
describe('formatBytes', () => {
it('should format 0 bytes', () => {
expect(formatBytes(0)).toBe('0 B');
});
it('should format bytes less than 1024', () => {
expect(formatBytes(1)).toBe('1 B');
expect(formatBytes(100)).toBe('100 B');
expect(formatBytes(500)).toBe('500 B');
expect(formatBytes(512)).toBe('512 B');
expect(formatBytes(1023)).toBe('1023 B');
});
it('should format kilobytes', () => {
expect(formatBytes(1024)).toBe('1.0 KB');
expect(formatBytes(1025)).toBe('1.0 KB');
expect(formatBytes(1536)).toBe('1.5 KB');
expect(formatBytes(2048)).toBe('2.0 KB');
});
it('should format megabytes', () => {
expect(formatBytes(1048576)).toBe('1.00 MB');
expect(formatBytes(1572864)).toBe('1.50 MB');
expect(formatBytes(5242880)).toBe('5.00 MB');
});
it('should format gigabytes', () => {
expect(formatBytes(1073741824)).toBe('1.00 GB');
expect(formatBytes(2147483648)).toBe('2.00 GB');
});
it('should format terabytes', () => {
expect(formatBytes(1099511627776)).toBe('1.00 TB');
expect(formatBytes(2199023255552)).toBe('2.00 TB');
});
it('should handle large values beyond TB', () => {
// Should cap at TB
expect(formatBytes(1125899906842624)).toBe('1024.00 TB');
});
});