Files
AeroFetch/test/id.test.ts
T
debont80 9134e7d216 feat(audit): Batch 25 — project reorg (CC12), leading DI args (CC7), CC10 by-design
CC12: renderer views/ (5 screens + Onboarding + settings cards) +
lib/ (theme/thumb/datetime/id/qualityOptions/useClipboardLink/queueStats);
main core/ (buildArgs/validation/indexerCore/ytdlpPolicy). git mv preserved
history; all src+test imports updated. Build emits view chunks from views/,
344 tests + typecheck green, live probe rendered all screens.
CC7: wc/onProgress is the leading arg everywhere — downloadAppUpdate(wc,url),
indexSource(onProgress,url,signal), indexSourceCancelable(onProgress,url).
CC10: closed by-design — jsonStore backs all records; settings stay in
electron-store for DPAPI secret encryption (a deliberate two-store split).
Also closes the UI24/W4 context-menu cross-reference.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 15:37:28 -04:00

29 lines
977 B
TypeScript

import { describe, it, expect } from 'vitest'
import { newId } from '../src/renderer/src/lib/id'
describe('newId', () => {
it('produces unique ids across many calls', () => {
const ids = new Set(Array.from({ length: 1000 }, () => newId('item')))
expect(ids.size).toBe(1000)
})
it('returns a non-empty string', () => {
expect(newId('tpl')).toBeTruthy()
expect(typeof newId('t')).toBe('string')
})
it('falls back to a prefixed, collision-free id when crypto.randomUUID is absent', () => {
const orig = globalThis.crypto
// Simulate a host without randomUUID; the counter suffix must keep same-ms ids distinct.
Object.defineProperty(globalThis, 'crypto', { value: {}, configurable: true })
try {
const a = newId('item')
const b = newId('item')
expect(a).toMatch(/^item-/)
expect(a).not.toBe(b)
} finally {
Object.defineProperty(globalThis, 'crypto', { value: orig, configurable: true })
}
})
})