import { describe, it, expect } from 'vitest' import { createBoundedDedup } from './bounded-dedup' describe('createBoundedDedup', () => { it('reports a key only the first time it is seen', () => { const dedup = createBoundedDedup(10) expect(dedup.firstSeen('a')).toBe(true) expect(dedup.firstSeen('a')).toBe(false) expect(dedup.firstSeen('b')).toBe(true) }) it('evicts wholesale at the cap, so a bounded footprint beats permanence', () => { const dedup = createBoundedDedup(2) expect(dedup.firstSeen('a')).toBe(true) expect(dedup.firstSeen('b')).toBe(true) // Cap hit — the set clears, then records 'c'. expect(dedup.firstSeen('c')).toBe(true) // 'a' was evicted: it may report once more (storm guard, not a ledger). expect(dedup.firstSeen('a')).toBe(true) // 'c' survived the post-eviction add. expect(dedup.firstSeen('c')).toBe(false) }) })