import { describe, expect, it } from 'vitest'; import { resolveMaxCount, resolveTimelineHours } from '../lib/analytics'; describe('resolveMaxCount', () => { it('defaults to 1 for empty input', () => { expect(resolveMaxCount([])).toBe(1); }); it('returns the highest count', () => { expect(resolveMaxCount([2, 5, 3])).toBe(5); }); it('never returns less than 1', () => { expect(resolveMaxCount([0])).toBe(1); }); }); describe('resolveTimelineHours', () => { it('uses fallback when data is missing', () => { expect(resolveTimelineHours([], 12)).toBe(12); }); it('calculates rounded hours from timestamps', () => { const start = new Date('2024-01-01T10:00:00Z').toISOString(); const end = new Date('2024-01-01T21:00:00Z').toISOString(); expect(resolveTimelineHours([start, end], 12)).toBe(11); }); it('never returns less than 1', () => { const start = new Date('2024-01-01T10:00:00Z').toISOString(); expect(resolveTimelineHours([start, start], 12)).toBe(1); }); });