We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 4a93dfb + 9c4b121 commit 4753b85Copy full SHA for 4753b85
test/Container.spec.ts
@@ -264,6 +264,35 @@ describe("Container", function() {
264
265
});
266
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
296
297
298
0 commit comments