UNPKG

@amsterdam/design-system-react

Version:

All React components from the Amsterdam Design System. Use it to compose pages in your website or application.

27 lines (26 loc) 924 B
/** * @license EUPL-1.2+ * Copyright Gemeente Amsterdam */ import { describe, expect, it } from 'vitest'; import { formatFileSize } from './formatFileSize'; describe('formatFileSize', () => { it('returns "0 bytes" for a file size of 0', () => { expect(formatFileSize(0)).toBe('0 bytes'); }); it('formats bytes correctly', () => { expect(formatFileSize(500)).toBe('500 bytes'); }); it('formats kilobytes correctly', () => { expect(formatFileSize(1024, 1)).toBe('1 kB'); expect(formatFileSize(2048, 1)).toBe('2 kB'); }); it('formats megabytes correctly', () => { expect(formatFileSize(1048576, 1)).toBe('1 MB'); expect(formatFileSize(2097152, 1)).toBe('2 MB'); }); it('formats gigabytes correctly', () => { expect(formatFileSize(1073741824, 1)).toBe('1 GB'); expect(formatFileSize(2147483648, 1)).toBe('2 GB'); }); });