mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
Merge pull request #16005 from malkovitc/fix/resolve-each-multiple-providers
fix(core): resolve all providers when using resolve() with each option
This commit is contained in:
@@ -24,7 +24,7 @@ describe('Multiple providers under the same token ("each" feature)', () => {
|
||||
});
|
||||
});
|
||||
describe('resolve()', () => {
|
||||
it('should return an array of providers', async () => {
|
||||
it('should return an array of request-scoped providers', async () => {
|
||||
const builder = Test.createTestingModule({
|
||||
imports: [MultipleProvidersModule],
|
||||
});
|
||||
@@ -43,5 +43,25 @@ describe('Multiple providers under the same token ("each" feature)', () => {
|
||||
|
||||
expect(multiProviderInstances).to.be.eql(['A', 'B', 'C']);
|
||||
});
|
||||
|
||||
it('should return an array of default-scoped providers', async () => {
|
||||
const builder = Test.createTestingModule({
|
||||
imports: [MultipleProvidersModule],
|
||||
});
|
||||
const testingModule = await builder.compile();
|
||||
|
||||
const multiProviderInstances = await testingModule.resolve<string>(
|
||||
'MULTI_PROVIDER',
|
||||
undefined,
|
||||
{
|
||||
each: true,
|
||||
},
|
||||
);
|
||||
|
||||
// @ts-expect-error: make sure "multiProviderInstances" is string[] not string
|
||||
multiProviderInstances.charAt;
|
||||
|
||||
expect(multiProviderInstances).to.be.eql(['A', 'B', 'C']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user