We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1371fd9 commit 47aad1eCopy full SHA for 47aad1e
test/decorators/Service.spec.ts
@@ -188,4 +188,19 @@ describe('Service Decorator', function () {
188
expect(Container.get<string>('my-service-A')).toBe('TEST_STRING');
189
expect(Container.get<string>('my-service-B')).toBe('TEST_STRING');
190
});
191
+
192
+ it('should support factory functions', function () {
193
+ class Engine {
194
+ public serialNumber = 'A-123';
195
+ }
196
197
+ @Service({
198
+ factory: () => new Car(new Engine()),
199
+ })
200
+ class Car {
201
+ constructor(public engine: Engine) {}
202
203
204
+ expect(Container.get(Car).engine.serialNumber).toBe('A-123');
205
+ });
206
0 commit comments