From fa7cbf9bb1d334d3129328da3aa76ddfd6e44022 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Thu, 5 Feb 2015 09:44:50 -0800 Subject: [PATCH] test(di): add a test to di checking that child bindings are not used when resolving the dependencies of a parent binding --- modules/angular2/test/di/injector_spec.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/angular2/test/di/injector_spec.js b/modules/angular2/test/di/injector_spec.js index 9897e2cf29..ee2ef4bfc8 100644 --- a/modules/angular2/test/di/injector_spec.js +++ b/modules/angular2/test/di/injector_spec.js @@ -262,6 +262,18 @@ export function main() { expect(engineFromChild).toBe(engineFromParent); }); + it("should not use the child bindings when resolving the dependencies of a parent binding", function () { + var parent = new Injector([ + Car, Engine + ]); + var child = parent.createChild([ + bind(Engine).toClass(TurboEngine) + ]); + + var carFromChild = child.get(Car); + expect(carFromChild.engine).toBeAnInstanceOf(Engine); + }); + it('should create new instance in a child injector', function () { var parent = new Injector([Engine]); var child = parent.createChild([