@@ -16,6 +16,7 @@ describe('RateLimitStoreFactory', () => {
1616 let registry : Registry ;
1717 let rateLimitStoreFailureCounter : Counter ;
1818 const testDuration = 5000 ;
19+ const mockRedisClient = { eval : ( ) => { } } as any ;
1920
2021 beforeEach ( ( ) => {
2122 logger = pino ( { level : 'silent' } ) ;
@@ -29,22 +30,12 @@ describe('RateLimitStoreFactory', () => {
2930 } ) ;
3031
3132 describe ( 'create' , ( ) => {
32- it ( 'should return LruRateLimitStore when redisClient is not provided' , ( ) => {
33- const store = RateLimitStoreFactory . create ( logger , testDuration ) ;
34-
35- expect ( store ) . to . be . instanceOf ( LruRateLimitStore ) ;
36- } ) ;
37-
3833 it ( 'should return LruRateLimitStore when redisClient is undefined' , ( ) => {
3934 const store = RateLimitStoreFactory . create ( logger , testDuration , rateLimitStoreFailureCounter , undefined ) ;
40-
4135 expect ( store ) . to . be . instanceOf ( LruRateLimitStore ) ;
4236 } ) ;
4337
4438 it ( 'should return RedisRateLimitStore when redisClient is provided' , ( ) => {
45- // Mock Redis client - just needs to be a truthy object for the factory logic
46- const mockRedisClient = { eval : ( ) => { } } as any ;
47-
4839 const store = RateLimitStoreFactory . create ( logger , testDuration , rateLimitStoreFailureCounter , mockRedisClient ) ;
4940
5041 expect ( store ) . to . be . instanceOf ( RedisRateLimitStore ) ;
@@ -57,30 +48,17 @@ describe('RateLimitStoreFactory', () => {
5748 } ) ;
5849
5950 it ( 'should return RedisRateLimitStore with failure counter' , ( ) => {
60- const mockRedisClient = { eval : ( ) => { } } as any ;
61-
6251 const store = RateLimitStoreFactory . create ( logger , testDuration , rateLimitStoreFailureCounter , mockRedisClient ) ;
6352
6453 expect ( store ) . to . be . instanceOf ( RedisRateLimitStore ) ;
6554 } ) ;
6655
6756 it ( 'should create different store instances on multiple calls' , ( ) => {
6857 const store1 = RateLimitStoreFactory . create ( logger , testDuration ) ;
69- const store2 = RateLimitStoreFactory . create ( logger , testDuration ) ;
70-
71- expect ( store1 ) . to . not . equal ( store2 ) ;
72- expect ( store1 ) . to . be . instanceOf ( LruRateLimitStore ) ;
73- expect ( store2 ) . to . be . instanceOf ( LruRateLimitStore ) ;
74- } ) ;
75-
76- it ( 'should create different Redis store instances on multiple calls' , ( ) => {
77- const mockRedisClient = { eval : ( ) => { } } as any ;
78-
79- const store1 = RateLimitStoreFactory . create ( logger , testDuration , rateLimitStoreFailureCounter , mockRedisClient ) ;
8058 const store2 = RateLimitStoreFactory . create ( logger , testDuration , rateLimitStoreFailureCounter , mockRedisClient ) ;
8159
8260 expect ( store1 ) . to . not . equal ( store2 ) ;
83- expect ( store1 ) . to . be . instanceOf ( RedisRateLimitStore ) ;
61+ expect ( store1 ) . to . be . instanceOf ( LruRateLimitStore ) ;
8462 expect ( store2 ) . to . be . instanceOf ( RedisRateLimitStore ) ;
8563 } ) ;
8664 } ) ;
0 commit comments