|
|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import { describe, it, expect, beforeEach, afterEach } from 'bun:test';
|
|
|
|
|
import { describe, it, expect, beforeEach, afterEach, beforeAll, afterAll } from 'bun:test';
|
|
|
|
|
import { Database } from 'bun:sqlite';
|
|
|
|
|
import { initializeDatabase, ensureUserExists } from '../../../src/db';
|
|
|
|
|
import { TaskService } from '../../../src/tasks/service';
|
|
|
|
|
@ -6,17 +6,23 @@ import { setDb, resetDb } from '../../../src/db/locator';
|
|
|
|
|
|
|
|
|
|
let memDb: Database;
|
|
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
beforeAll(() => {
|
|
|
|
|
memDb = new Database(':memory:');
|
|
|
|
|
initializeDatabase(memDb);
|
|
|
|
|
setDb(memDb);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
try {
|
|
|
|
|
resetDb();
|
|
|
|
|
memDb.close();
|
|
|
|
|
} catch {}
|
|
|
|
|
afterAll(() => {
|
|
|
|
|
try { resetDb(); memDb.close(); } catch {}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
// Reafirmar el locator y limpiar tablas relevantes entre tests
|
|
|
|
|
setDb(memDb);
|
|
|
|
|
try { memDb.exec('DELETE FROM task_assignments'); } catch {}
|
|
|
|
|
try { memDb.exec('DELETE FROM tasks'); } catch {}
|
|
|
|
|
try { memDb.exec('DELETE FROM users'); } catch {}
|
|
|
|
|
try { memDb.exec('DELETE FROM groups'); } catch {}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('TaskService.listGroupUnassigned / countGroupUnassigned', () => {
|
|
|
|
|
|