/** * Test DB fixture helpers. * * For unit tests (Tasks 1-2 scope): provides mock/stub helpers so tests can run * without a real MariaDB connection. Plan 02/03 will fill in integration-style * fixtures that hit the Docker MariaDB (DB_HOST=127.0.0.1 from the dev compose override). */ // Re-export vi for convenience in test files export { vi } from 'vitest' /** * Creates a minimal mock for the Drizzle `db` singleton. * Replace individual methods per test as needed. * * Plan 02 (auth) will extend this with a real test-schema fixture. * Plan 03 (broker) will extend with event-fixture helpers. */ export function createMockDb() { return { select: vi.fn().mockReturnThis(), from: vi.fn().mockReturnThis(), where: vi.fn().mockReturnThis(), limit: vi.fn().mockResolvedValue([]), insert: vi.fn().mockReturnThis(), values: vi.fn().mockReturnThis(), onDuplicateKeyUpdate: vi.fn().mockResolvedValue([{ id: 1 }]), $returningId: vi.fn().mockResolvedValue([{ id: 1 }]), execute: vi.fn().mockResolvedValue([]), } } /** * Sample VEVENT string for broker tests — a timed event (Plan 03). */ export const SAMPLE_VEVENT_TIMED = `BEGIN:VCALENDAR VERSION:2.0 PRODID:-//FamilySync//Test//EN BEGIN:VEVENT UID:test-timed-event-001@familysync DTSTART:20260615T100000Z DTEND:20260615T110000Z SUMMARY:Test Timed Event END:VEVENT END:VCALENDAR` /** * Sample VEVENT string for broker tests — an all-day event (Plan 03). */ export const SAMPLE_VEVENT_ALLDAY = `BEGIN:VCALENDAR VERSION:2.0 PRODID:-//FamilySync//Test//EN BEGIN:VEVENT UID:test-allday-event-001@familysync DTSTART;VALUE=DATE:20260615 DTEND;VALUE=DATE:20260616 SUMMARY:Test All-Day Event END:VEVENT END:VCALENDAR`