Created
August 10, 2017 20:18
-
-
Save yury-sannikov/8ecc209f6f46c245d79edd085f6d3ca4 to your computer and use it in GitHub Desktop.
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
poolForChanges(so) { | |
// Prepare environment | |
const component = componentFactory({}); | |
const callback = sinon.spy(); | |
// Invoke component helper method | |
helper.poolForChanges(component, callback); | |
// helper method should call another helper method. | |
// It's second parameter has a callback we are going to test | |
expect(helper.pullSummary).to.have.been.called; | |
const [{args: [,pullTicketSummaryCallback]}] = helper.pullSummary.getCalls(); | |
// Invoke pullSummary's callback we extracted from stubbed pullSummary helper method | |
pullSummaryCallback(so); | |
// An outer callback should not called because inside pullSummaryCallback helper method has setTimeout() call | |
expect(callback).not.to.have.been.called; | |
this.clock.tick(751); | |
// Outer callback will be called after a timeout in a synchronous manner | |
expect(callback).to.have.been.called; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment