import { describe, expect, it } from 'vitest'; import { newId } from '@/lib/id'; describe('newId', () => { it('returns a string without prefix when called bare', () => { const id = newId(); expect(typeof id).toBe('string'); expect(id.length).toBe(12); }); it('prefixes when asked', () => { expect(newId('finding')).toMatch(/^finding_[A-Za-z0-9_-]{10}$/); }); it('is unique across 1000 calls', () => { const ids = new Set(Array.from({ length: 1000 }, () => newId())); expect(ids.size).toBe(1000); }); });