Created
September 26, 2014 22:34
-
-
Save MichaelSitter/7a1fc21422b25f141104 to your computer and use it in GitHub Desktop.
Jasmine spy promise strategies
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
// Add to boot.js | |
jasmine.SpyStrategy.prototype.returnResolvedPromise = function(promiseApi, resolvedValue) { | |
return this.callFake(function() { | |
var def = promiseApi.defer(); | |
def.resolve(resolvedValue); | |
return def.promise; | |
}); | |
}; | |
jasmine.SpyStrategy.prototype.returnRejectedPromise = function(promiseApi, rejectValue) { | |
return this.callFake(function() { | |
var def = promiseApi.defer(); | |
def.reject(rejectValue); | |
return def.promise; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment