- Device domain: updateFromValues, organizeParameters, identifier - BaseModel: full CRUD mock tests - DeviceModel: all methods mocked - Other models: collectionName verification - MainStateMachine: start, handleResponse, state transitions - ConfigurationEvaluationState: init, GPN flow, GPN-unsupported skip - MongodbProvider: getMongoDb guard - device_utils: hash determinism - vitest.config.ts: coverage scope (excludes HTTP layer) - 492 tests passing, 78% line coverage
21 lines
709 B
TypeScript
21 lines
709 B
TypeScript
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')
|
|
})
|
|
})
|