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:
parent
6bfa48bc64
commit
fa7cbf9bb1
|
@ -262,6 +262,18 @@ export function main() {
|
||||||
expect(engineFromChild).toBe(engineFromParent);
|
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 () {
|
it('should create new instance in a child injector', function () {
|
||||||
var parent = new Injector([Engine]);
|
var parent = new Injector([Engine]);
|
||||||
var child = parent.createChild([
|
var child = parent.createChild([
|
||||||
|
|
Loading…
Reference in New Issue