Skip to content

Commit

Permalink
test: add missing decorator use case (#1117)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrel committed Jun 12, 2023
1 parent 1371fd9 commit 4c8c301
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/decorators/Service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,19 @@ describe('Service Decorator', function () {
expect(Container.get<string>('my-service-A')).toBe('TEST_STRING');
expect(Container.get<string>('my-service-B')).toBe('TEST_STRING');
});

it('should support factory functions', function () {
class Engine {
public serialNumber = 'A-123';
}

@Service({
factory: () => new Car(new Engine()),
})
class Car {
constructor(public engine: Engine) {}
}

expect(Container.get(Car).engine.serialNumber).toBe('A-123');
});
});

0 comments on commit 4c8c301

Please sign in to comment.