import { describe, expect, it } from 'vitest' import { scanEmptyNote, scanTruncationNote, type ScanSummary } from './scan-note' function summary(overrides: Partial = {}): ScanSummary { return { posts_read: 100, truncated: false, oldest_post_date: null, longest_chain: 10, ...overrides, } } describe('scanTruncationNote', () => { it('says how many posts were read, how far back, and what was missed', () => { const result = summary({ posts_read: 20_000, truncated: true, oldest_post_date: '2012-03-04', }) expect(scanTruncationNote(result)).toBe( `Read ${(20_000).toLocaleString()} posts, back to 2012-03-04. Older posts were not read.`, ) }) it('is empty for a complete scan', () => { expect(scanTruncationNote(summary())).toBe('') }) }) describe('scanEmptyNote', () => { it('does not name a lookback window', () => { expect(scanEmptyNote(summary({ posts_read: 0 }))).toBe('No posts found.') expect(scanEmptyNote(summary({ longest_chain: 0 }))).toBe('No self-thread chains found.') }) })