Skip to content

Commit 47aad1e

Browse files
committed
test: add missing decorator use case
1 parent 1371fd9 commit 47aad1e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/decorators/Service.spec.ts

+15
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,19 @@ describe('Service Decorator', function () {
188188
expect(Container.get<string>('my-service-A')).toBe('TEST_STRING');
189189
expect(Container.get<string>('my-service-B')).toBe('TEST_STRING');
190190
});
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+
});
191206
});

0 commit comments

Comments
 (0)