/* eslint-env jest */ import type { ScanHistoryPoint, WeeklyReportResponse, } from '../../../service/visibility/visibility.interface'; import { pulseNumbers } from '../pulse-numbers'; const w38: ScanHistoryPoint = { date: '2026-09-15', week_iso: '2026-W38', visibility_score: 22, share_of_voice: 3, queries_checked: 24, brand_mentions: 4, }; describe('the headline of a week', () => { it('reads the latest scan, all of it, when the week has no report yet', () => { const numbers = pulseNumbers(null, [w38], '2026-W39'); expect(numbers.score).toBe(22); expect(numbers.shareOfVoice).toBe(3); expect(numbers.point?.brand_mentions).toBe(4); expect(numbers.scanWeek).toBe('2026-W38'); }); it('reads the report when there is one', () => { const report = { visibility_score: 30, share_of_voice: 5, } as unknown as WeeklyReportResponse; const numbers = pulseNumbers(report, [w38], '2026-W38'); expect(numbers.score).toBe(30); expect(numbers.scanWeek).toBeNull(); }); });