aboutsummaryrefslogtreecommitdiffstats
path: root/test/AngularSpec.js
diff options
context:
space:
mode:
authorDi Peng2011-06-22 10:14:56 -0700
committerIgor Minar2011-06-23 07:56:58 -0700
commit65b6e4874275986607efaf66c3814f3b3a559399 (patch)
tree2e1a4ea03a001165201f2a8b30637557b480c801 /test/AngularSpec.js
parentfee3717892498c63c24821104e99efab7c9ac177 (diff)
downloadangular.js-65b6e4874275986607efaf66c3814f3b3a559399.tar.bz2
test:angular.service - add tests for $inject
Diffstat (limited to 'test/AngularSpec.js')
-rw-r--r--test/AngularSpec.js18
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() {