Skip to content

Commit 9c4b121

Browse files
author
Slava Fomin II
committed
Added broken test to demonstrate a use case.
1 parent 38fd0c6 commit 9c4b121

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/Container.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,35 @@ describe("Container", function() {
264264

265265
});
266266

267+
it("should support tokenized services from factories", function() {
268+
269+
interface Vehicle {
270+
getColor(): string;
271+
}
272+
273+
class Bus implements Vehicle {
274+
getColor (): string {
275+
return "yellow";
276+
}
277+
}
278+
279+
class VehicleFactory {
280+
createBus(): Vehicle {
281+
return new Bus();
282+
}
283+
}
284+
285+
const VehicleService = new Token<Vehicle>();
286+
287+
Container.registerService({
288+
id: VehicleService,
289+
factory: [VehicleFactory, "createBus"]
290+
});
291+
292+
Container.get(VehicleService).getColor().should.be.equal("yellow");
293+
294+
});
295+
267296
});
268297

269298
});

0 commit comments

Comments
 (0)