22 lines
796 B
TypeScript
22 lines
796 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { bucharestClock, uptimeSince } from '@/lib/operations';
|
|
|
|
describe('uptimeSince', () => {
|
|
const start = new Date('2025-08-01T00:00:00Z');
|
|
it('is zero at the start', () => {
|
|
expect(uptimeSince(start, start)).toEqual({ months: 0, days: 0 });
|
|
});
|
|
it('counts whole months and remaining days', () => {
|
|
expect(uptimeSince(start, new Date('2026-10-10T00:00:00Z'))).toEqual({ months: 14, days: 9 });
|
|
});
|
|
it('clamps to zero before the start', () => {
|
|
expect(uptimeSince(start, new Date('2025-01-01T00:00:00Z'))).toEqual({ months: 0, days: 0 });
|
|
});
|
|
});
|
|
|
|
describe('bucharestClock', () => {
|
|
it('formats HH:MM in Europe/Bucharest', () => {
|
|
expect(bucharestClock(new Date('2026-01-15T10:05:00Z'))).toBe('12:05');
|
|
});
|
|
});
|