Created
January 31, 2017 20:16
-
-
Save JoshuaKGoldberg/59aeb2ab8dc370cbc0474b86d3a1e4c7 to your computer and use it in GitHub Desktop.
Sinon stub with a return value
This file contains hidden or 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
attempt_CallsOnFail_IfMyApiFails() { | |
// Arrange | |
const onFail = sinon.stub(); | |
const onSucceed = sinon.stub(); | |
const externalApi = sinon.stub().returns(false); | |
const actor = new Actor({ externalApi, onFail, onSucceed }); | |
// Act | |
actor.attempt(); // internally calls externalApi | |
// Assert | |
UTF.Assert.True("onFail should have been called", onFail.calledOnce); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment