Skip to content

Commit 65b6e48

Browse files
Di PengIgorMinar
Di Peng
authored andcommitted
test:angular.service - add tests for $inject
1 parent fee3717 commit 65b6e48

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/AngularSpec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,24 @@ describe('angular', function(){
498498
expect(result.two).not.toBeDefined();
499499
expect(result.third).toBeTruthy();
500500
});
501+
502+
it('should inject dependencies specified by $inject', function() {
503+
angular.service('svc1', function() { return 'svc1'; });
504+
angular.service('svc2', function(svc1) { return 'svc2-' + svc1; }, {$inject: ['svc1']});
505+
expect(angular.scope().$service('svc2')).toEqual('svc2-svc1');
506+
});
507+
508+
it('should inject dependencies specified by $inject and ignore function argument name', function() {
509+
angular.service('svc1', function() { return 'svc1'; });
510+
angular.service('svc2', function(foo) { return 'svc2-' + foo; }, {$inject: ['svc1']});
511+
expect(angular.scope().$service('svc2')).toEqual('svc2-svc1');
512+
});
513+
514+
it('should inject infered dependencies when $inject is missing', function() {
515+
angular.service('svc1', function() { return 'svc1'; });
516+
angular.service('svc2', function(svc1) { return 'svc2-' + svc1; });
517+
expect(angular.scope().$service('svc2')).toEqual('svc2-svc1');
518+
});
501519
});
502520

503521
describe('isDate', function() {

0 commit comments

Comments
 (0)