Created
February 14, 2020 10:14
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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