test(di): add a test to di checking that child bindings are not used when resolving the dependencies of a parent binding

This commit is contained in:
vsavkin 2015-02-05 09:44:50 -08:00
parent 6bfa48bc64
commit fa7cbf9bb1
1 changed files with 12 additions and 0 deletions

View File

@ -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([