How to use the pouchdb-browser.putIfNotExistsMock.mockImplementationOnce function in pouchdb-browser

To help you get started, we’ve selected a few pouchdb-browser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ArkEcosystem / desktop-wallet / __tests__ / unit / store / db / interface.spec.js View on Github external
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)
    })