frontend/tests/format.test.ts

12 lines
510 B
TypeScript

import { describe, it, expect } from 'vitest';
import { truncate, bytesToHuman } from '../src/utils/format';
describe('truncate', () => {
it('leaves short strings alone', () => expect(truncate('hi', 10)).toBe('hi'));
it('truncates long strings', () => expect(truncate('hello world', 7)).toBe('hello w…'));
});
describe('bytesToHuman', () => {
it('formats bytes', () => expect(bytesToHuman(1024)).toBe('1.0 KB'));
it('formats megabytes', () => expect(bytesToHuman(1536 * 1024)).toBe('1.5 GB'));
});