9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { formatDuration, formatDate } from './utils.js';
|
|
describe('formatDuration', () => {
|
|
it('formats typical duration', () => {
|
|
expect(formatDuration(3890)).toBe('64:50');
|
|
});
|
|
it('formats zero seconds', () => {
|
|
expect(formatDuration(0)).toBe('0:00');
|
|
});
|
|
it('pads single-digit seconds', () => {
|
|
expect(formatDuration(62)).toBe('1:02');
|
|
});
|
|
it('handles exact minutes', () => {
|
|
expect(formatDuration(120)).toBe('2:00');
|
|
});
|
|
it('rounds fractional seconds', () => {
|
|
expect(formatDuration(65.7)).toBe('1:06');
|
|
});
|
|
it('returns dash for NaN', () => {
|
|
expect(formatDuration(NaN)).toBe('-');
|
|
});
|
|
it('returns dash for negative', () => {
|
|
expect(formatDuration(-1)).toBe('-');
|
|
});
|
|
it('returns dash for Infinity', () => {
|
|
expect(formatDuration(Infinity)).toBe('-');
|
|
});
|
|
});
|
|
describe('formatDate', () => {
|
|
it('slices ISO string to date', () => {
|
|
expect(formatDate('2026-03-15T12:00:00Z')).toBe('2026-03-15');
|
|
});
|
|
it('returns dash for empty string', () => {
|
|
expect(formatDate('')).toBe('-');
|
|
});
|
|
it('returns dash for undefined', () => {
|
|
expect(formatDate(undefined)).toBe('-');
|
|
});
|
|
});
|