Skip to content

Instantly share code, notes, and snippets.

@deanbudd
Created October 2, 2017 22:28
Show Gist options
  • Save deanbudd/9cf25b587c71f60b5055c16da18744a4 to your computer and use it in GitHub Desktop.
Save deanbudd/9cf25b587c71f60b5055c16da18744a4 to your computer and use it in GitHub Desktop.
const sinon = require('sinon')
const componentIWantToMock = {
functionIWantToMock: function() {}
}
const componentThatUsesMock = {
someFunction: function(mock) {
mock.functionIWantToMock()
}
}
const mockComponent = sinon.mock(componentIWantToMock)
mockComponent.expects('functionIWantToMock').once()
componentThatUsesMock.someFunction(componentIWantToMock)
mockComponent.verify()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment