How to use sourced-repo-mongo - 4 common examples

To help you get started, we’ve selected a few sourced-repo-mongo 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 patrickleet / servicebus-microservice / __tests__ / unit / lib / repos / todoListRepository.js View on Github external
it('is a singleton', () => {
    let repo = require('sourced-repo-mongo')

    let todoListRepository2 = require('repos/todoListRepository.mjs').todoListRepository
    let todoListRepository3 = require('repos/todoListRepository.mjs').todoListRepository

    expect(repo.Repository).toHaveBeenCalledTimes(1)
    expect(todoListRepository).toBeDefined()
    expect(todoListRepository).toBe(todoListRepository2)
    expect(todoListRepository2).toBe(todoListRepository3)
  })
})
github patrickleet / servicebus-microservice / __tests__ / unit / bin / start.js View on Github external
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()
  })
})

sourced-repo-mongo

mongo data store and repository for sourced-style event sourcing models

MIT
Latest version published 3 years ago

Package Health Score

46 / 100
Full package analysis