import { describe, it, expect, beforeEach } from 'vitest'; import { resetDb } from '../helpers/db.js'; import { migrateUp } from '../../lib/db/migrate.js'; import * as clips from '../../lib/db/repos/voice_clips.js'; beforeEach(async () => { await resetDb(); await migrateUp(); }); describe('voice_clips repo', () => { it('creates, lists newest-first, and removes (returning path)', async () => { const a = await clips.create({ transcript: 'first', bytes: 10, mime: 'audio/webm', path: '/x/a.webm' }); const b = await clips.create({ transcript: 'second', bytes: 20, mime: 'audio/webm', path: '/x/b.webm' }); const list = await clips.list(); expect(list.length).toBe(2); expect(list[0].transcript).toBe('second'); // newest first const removed = await clips.remove(a.id); expect(removed.path).toBe('/x/a.webm'); expect((await clips.list()).length).toBe(1); }); });