From fbcb7fdd141c277d326dc3ed34545210c4d5628f Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 22 Feb 2012 11:31:49 -0800 Subject: fix($injector): circular dependency instatiation --- test/InjectorSpec.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/InjectorSpec.js') 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'); + }); }); }); -- cgit v1.2.3