aboutsummaryrefslogtreecommitdiffstats
path: root/test/InjectorSpec.js
diff options
context:
space:
mode:
authorMisko Hevery2012-02-22 11:31:49 -0800
committerMisko Hevery2012-02-22 11:32:09 -0800
commitfbcb7fdd141c277d326dc3ed34545210c4d5628f (patch)
treec69844d52dd52bbff0b8179098f305c0054241a0 /test/InjectorSpec.js
parentfa69d10122458fb92b311ca5e30a5804c03c0778 (diff)
downloadangular.js-fbcb7fdd141c277d326dc3ed34545210c4d5628f.tar.bz2
fix($injector): circular dependency instatiation
Diffstat (limited to 'test/InjectorSpec.js')
-rw-r--r--test/InjectorSpec.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/InjectorSpec.js b/test/InjectorSpec.js
index df326580..e0cabbac 100644
--- a/test/InjectorSpec.js
+++ b/test/InjectorSpec.js
@@ -483,6 +483,27 @@ describe('injector', function() {
createInjector([['$injector', myModule]]);
}).toThrow('Unknown provider: $injector from ' + myModule);
});
+
+
+ it('should throw error when trying to inject oneself', function() {
+ expect(function() {
+ createInjector([function($provide){
+ $provide.factory('service', function(service){});
+ return function(service) {}
+ }])
+ }).toThrow('Circular dependency: service');
+ });
+
+
+ it('should throw error when trying to inject circular dependency', function() {
+ expect(function() {
+ createInjector([function($provide){
+ $provide.factory('a', function(b){});
+ $provide.factory('b', function(a){});
+ return function(a) {}
+ }])
+ }).toThrow('Circular dependency: b <- a');
+ });
});
});