import { describe, it, expect, vi } from 'vitest' // We can't fully test the provider without an app context, // but we can test the getMongoDb function behavior vi.mock('mongodb', () => ({ MongoClient: vi.fn().mockImplementation(() => ({ connect: vi.fn().mockResolvedValue(undefined), db: vi.fn().mockReturnValue({ collection: vi.fn() }), close: vi.fn().mockResolvedValue(undefined), })), })) describe('MongodbProvider', () => { it('getMongoDb throws when not booted', async () => { // Reset module state vi.resetModules() const { getMongoDb } = await import('../../../providers/mongodb_provider.js') expect(() => getMongoDb()).toThrow('MongoDB is not connected') }) })