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 save the Model as a document and return it updated', async () => {
const _rev = 'revision-1'
putIfNotExistsMock.mockImplementationOnce(docToCreate => {
if (_.isEqual(docToCreate, model.doc)) {
return { updated: true, rev: _rev }
}
return { updated: false }
})
const result = await db.create(model)
const updatedModel = new TestModel(Object.assign(model.doc, { _rev }))
expect(result).toBeInstanceOf(TestModel)
expect(result).toEqual(updatedModel)
expect(putIfNotExistsMock).toHaveBeenCalledWith(model.doc)
})