测试服务,我做这个控制器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