Complete test coverage implementation for errors.bitreport.pt: admin-ui (98 tests): - test/components/: AppShell, DataAlert, IncidentNotes, KpiCard, SeverityBadge, StateBadge - test/lib/: format, demo-incidents, incidents-data, incidents-data-api, stats-data, stats-data-api - vitest.config.ts with jsdom + v8 coverage + @vitejs/plugin-react api route tests (54 tests): - src/routes/admin/auth.test.ts (15 tests) - src/routes/admin/incidents.test.ts (11 tests) - src/routes/admin/stats.test.ts (18 tests) - src/routes/public/errorMonitoringStats.test.ts (10 tests) collector-worker db/scheduler tests (22 tests): - src/db/collectorRunWriter.test.ts (10 tests) - src/db/loadActiveSources.test.ts (6 tests) - src/scheduler/runHttpSourceOnce.test.ts (6 tests) ingest-api service tests (13 tests): - src/buildApp.test.ts, plugins/prometheus.test.ts - services/ingestAuth.test.ts, services/processIngestBatch.utils.test.ts Total: 187 additional tests (255 total across all modules). All pass. Paperclip-Issue: BIT-15744 Co-Authored-By: Paperclip <[email protected]>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { formatDateTime } from '@/lib/format';
|
|
|
|
describe('formatDateTime', () => {
|
|
it('formats a valid ISO string', () => {
|
|
const result = formatDateTime('2024-01-15T10:30:00Z');
|
|
expect(typeof result).toBe('string');
|
|
expect(result.length).toBeGreaterThan(0);
|
|
expect(result).not.toBe('2024-01-15T10:30:00Z');
|
|
});
|
|
|
|
it('returns the raw string for an invalid date', () => {
|
|
expect(formatDateTime('not-a-date')).toBe('not-a-date');
|
|
});
|
|
|
|
it('returns the raw string for an empty string', () => {
|
|
expect(formatDateTime('')).toBe('');
|
|
});
|
|
|
|
it('handles date-only ISO strings', () => {
|
|
const result = formatDateTime('2024-06-01');
|
|
expect(typeof result).toBe('string');
|
|
expect(result.length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it('handles ISO strings with milliseconds', () => {
|
|
const result = formatDateTime('2024-03-20T14:22:33.456Z');
|
|
expect(typeof result).toBe('string');
|
|
expect(result).not.toBe('2024-03-20T14:22:33.456Z');
|
|
});
|
|
|
|
it('returns consistent output for the same input', () => {
|
|
const iso = '2024-07-04T12:00:00Z';
|
|
expect(formatDateTime(iso)).toBe(formatDateTime(iso));
|
|
});
|
|
});
|