Skip to content

Commit a495e5c

Browse files
committed
fix(client): fix forRootAsync method not looking at imports property
1 parent 32b3902 commit a495e5c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

packages/client/src/lib/module.int.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,35 @@ describe('RedisModule Integration forRootAsync', () => {
343343

344344
await defaultModule.close();
345345
});
346+
347+
it('should work with injected modules inside imports', async () => {
348+
const defaultModule = await Test.createTestingModule({
349+
imports: [
350+
RedisModule.forRootAsync({
351+
imports: [ConfigModule.forRoot({ isGlobal: true })],
352+
inject: [ConfigService],
353+
useFactory: (configService: ConfigService) => ({
354+
type: 'client',
355+
isGlobal: true,
356+
options: {
357+
url:
358+
configService.get<string>('REDIS_HOST') ??
359+
'redis://localhost:6379',
360+
},
361+
}),
362+
}),
363+
],
364+
}).compile();
365+
await defaultModule.init();
366+
367+
const defaultRedisClient = defaultModule.get<Redis>(RedisToken());
368+
369+
// Test basic operation
370+
const ping = await defaultRedisClient.ping();
371+
expect(ping).toBe('PONG');
372+
373+
await defaultModule.close();
374+
});
346375
});
347376
});
348377

packages/client/src/lib/module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class RedisModule
5252
module: class extends RedisModule {
5353
override connectionToken = RedisToken(options.connectionName);
5454
},
55+
imports: options.imports || [],
5556
providers: [
5657
...(baseModule.providers || []),
5758
this.getRedisClientProvider(options.connectionName),

0 commit comments

Comments
 (0)