import { db, initializeDatabase } from '../../src/db'; import { describe, test, expect, beforeEach } from 'bun:test'; describe('Database', () => { beforeEach(() => { // Reset database between tests db.exec('DROP TABLE IF EXISTS tasks'); db.exec('DROP TABLE IF EXISTS task_assignments'); db.exec('DROP TABLE IF EXISTS users'); db.exec('DROP TABLE IF EXISTS groups'); initializeDatabase(); }); test('should create all required tables with correct schema', () => { // Verify tables exist const tables = db .query("SELECT name FROM sqlite_master WHERE type='table'") .all() .map((t: any) => t.name); expect(tables.sort()).toEqual(['groups', 'task_assignments', 'tasks', 'users'].sort()); // Verify tasks table schema const tasksColumns = db .query("PRAGMA table_info(tasks)") .all() .map((c: any) => c.name); expect(tasksColumns).toContain('description'); expect(tasksColumns).toContain('due_date'); }); });