Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should throw an error if it cant connect to mongo', () => {
let mongoClient = require('sourced-repo-mongo/mongo')
mongoClient.connect = jest.fn(() => new Promise((resolve, reject) => { reject(new Error('MongoDB Error')) }))
const onStart = jest.fn()
expect(start(onStart)).rejects.toEqual(new Error('Error connecting to mongo'))
expect(onStart).not.toBeCalled()
})
})