Skip to content

Instantly share code, notes, and snippets.

@tehvicke
Created February 14, 2020 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tehvicke/c78fa9ea9fa8636a1bbba5262d33f3b6 to your computer and use it in GitHub Desktop.
Save tehvicke/c78fa9ea9fa8636a1bbba5262d33f3b6 to your computer and use it in GitHub Desktop.
Simple test using sinon in a mock model to listen on whether a function was called or not
describe('updateLike test', () => {
it('should updates the heart count', () => {
const MockModel = {
findOneAndUpdate: sinon.spy()
}
const thoughtService = ThoughtService(MockModel)
thoughtService.updateLikes()
const actual = MockModel.findOneAndUpdate.calledOnce
const expected = true
expect(actual).toEqual(expected)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment