Angular/Jasmine testing with deffered promises
问题 I am testing a controller using a combination of angular and jasmine, and am not completely sure about using deffered promises. This is my spec code. describe('Controller Tests', function(){ var scope, searchAPI; beforeEach(function(){ var mockSearchAPI = {}; module('myApp', function($provide){ $provide.value('searchAPI', mockSearchAPI); }); }); inject(function($q){ var testData = {"message":"hi"}; mockSearchAPI.executeSearch = function(){ var defer = $q.defer(); defer.resolve(testData);