Created
February 5, 2016 17:42
-
-
Save DorkForce/763ad715b5d5ee904995 to your computer and use it in GitHub Desktop.
Mock a service to return a promise
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
// from http://stackoverflow.com/questions/23705051/how-do-i-mock-a-service-that-returns-promise-in-angularjs-jasmine-unit-test | |
beforeEach(inject( function(_myService_, $q){ | |
myService = _myService_; | |
myOtherServiceMock.makeRemoteCallReturningPromise = function() { | |
var deferred = $q.defer(); | |
deferred.resolve('Remote call result'); | |
return deferred.promise; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment