diff options
| author | Di Peng | 2011-06-22 10:14:56 -0700 | 
|---|---|---|
| committer | Igor Minar | 2011-06-23 07:56:58 -0700 | 
| commit | 65b6e4874275986607efaf66c3814f3b3a559399 (patch) | |
| tree | 2e1a4ea03a001165201f2a8b30637557b480c801 /test/AngularSpec.js | |
| parent | fee3717892498c63c24821104e99efab7c9ac177 (diff) | |
| download | angular.js-65b6e4874275986607efaf66c3814f3b3a559399.tar.bz2 | |
test:angular.service - add tests for $inject
Diffstat (limited to 'test/AngularSpec.js')
| -rw-r--r-- | test/AngularSpec.js | 18 | 
1 files changed, 18 insertions, 0 deletions
| diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 4ab14580..a4d617b6 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -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() { | 
