You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1008 B
TypeScript

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');
});
});