mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-30 13:00:29 +00:00
test:angular.service - add tests for $inject
This commit is contained in:
parent
fee3717892
commit
65b6e48742
1 changed files with 18 additions and 0 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue