Skip to content

Commit fa7cbf9

Browse files
committed
test(di): add a test to di checking that child bindings are not used when resolving the dependencies of a parent binding
1 parent 6bfa48b commit fa7cbf9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

modules/angular2/test/di/injector_spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,18 @@ export function main() {
262262
expect(engineFromChild).toBe(engineFromParent);
263263
});
264264

265+
it("should not use the child bindings when resolving the dependencies of a parent binding", function () {
266+
var parent = new Injector([
267+
Car, Engine
268+
]);
269+
var child = parent.createChild([
270+
bind(Engine).toClass(TurboEngine)
271+
]);
272+
273+
var carFromChild = child.get(Car);
274+
expect(carFromChild.engine).toBeAnInstanceOf(Engine);
275+
});
276+
265277
it('should create new instance in a child injector', function () {
266278
var parent = new Injector([Engine]);
267279
var child = parent.createChild([

0 commit comments

Comments
 (0)