test:angular.service - add tests for $inject

This commit is contained in:
Di Peng 2011-06-22 10:14:56 -07:00 committed by Igor Minar
parent fee3717892
commit 65b6e48742

View file

@ -498,6 +498,24 @@ describe('angular', function(){
expect(result.two).not.toBeDefined();
expect(result.third).toBeTruthy();
});
it('should inject dependencies specified by $inject', function() {
angular.service('svc1', function() { return 'svc1'; });
angular.service('svc2', function(svc1) { return 'svc2-' + svc1; }, {$inject: ['svc1']});
expect(angular.scope().$service('svc2')).toEqual('svc2-svc1');
});
it('should inject dependencies specified by $inject and ignore function argument name', function() {
angular.service('svc1', function() { return 'svc1'; });
angular.service('svc2', function(foo) { return 'svc2-' + foo; }, {$inject: ['svc1']});
expect(angular.scope().$service('svc2')).toEqual('svc2-svc1');
});
it('should inject infered dependencies when $inject is missing', function() {
angular.service('svc1', function() { return 'svc1'; });
angular.service('svc2', function(svc1) { return 'svc2-' + svc1; });
expect(angular.scope().$service('svc2')).toEqual('svc2-svc1');
});
});
describe('isDate', function() {