test(core): add integration test for resolve() with each option on default-scoped providers

This commit is contained in:
evgeniy.chernomortsev
2025-12-09 18:36:45 +04:00
parent acb1ae56d4
commit 0b1a40df23

View File

@@ -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']);
});
});
});