測試服務,我做這個控制器AngularJs:茉莉
app.controller('controller',['$scope','httpServices',function($scope,httpServices){
$scope.items= undefined;
httpServices.getItems(function(items){
$scope.items= items;
});
}]);
和我寫了這個測試
describe('controller', function() {
beforeEach(inject(function ($rootScope, $controller) {
scope = $rootScope.$new();
controller = $controller('controller', {
'$scope': scope
});
}));
it('defined', function() {
expect(scope.items).toBeUndefined();
})
});
我如何測試scope.items已經叫售後服務?
任何你沒有從'httpServices.getItems'返回承諾的原因? – 2014-10-29 07:54:32