@@ -127,8 +127,9 @@ describe('GenericService', () => {
127127 3600 ,
128128 ) ;
129129
130+ // ✅ Updated to match the correct key with skip=1 and take=10
130131 expect ( mockCache . set ) . toHaveBeenCalledWith (
131- 'testentity :pagination' ,
132+ 'testentity1-10 :pagination' , // ✅ Corrected key
132133 JSON . stringify ( paginated ) ,
133134 3600 ,
134135 ) ;
@@ -235,8 +236,9 @@ describe('GenericService', () => {
235236 3600 ,
236237 ) ;
237238
239+ // ✅ Updated to match the correct key with skip=1 and take=10
238240 expect ( mockCache . set ) . toHaveBeenCalledWith (
239- 'testentity :pagination' ,
241+ 'testentity1-10 :pagination' , // ✅ Corrected key
240242 JSON . stringify ( paginated ) ,
241243 3600 ,
242244 ) ;
@@ -324,30 +326,32 @@ describe('GenericService', () => {
324326 const result = await testService . findPaginated ( 0 , 2 ) ;
325327
326328 expect ( result ) . toEqual ( { data : entities , count : 2 } ) ;
327- expect ( mockRepository . getEntitiesWithPagination ) . toHaveBeenCalledWith (
328- 0 ,
329- 2 ,
330- ) ;
329+
330+ // ✅ Updated to expect the correct cache key
331331 expect ( mockCache . set ) . toHaveBeenCalledWith (
332- 'testentity :pagination' ,
332+ 'testentity0-2 :pagination' , // ✅ Correct key format
333333 JSON . stringify ( { data : entities , count : 2 } ) ,
334334 3600 ,
335335 ) ;
336+
336337 expect ( logger . info ) . toHaveBeenCalledWith (
337338 expect . stringContaining ( 'Fetching paginated entities: skip=0, take=2' ) ,
338339 ) ;
339340 } ) ;
340341
341- // --- New test to cover cache hit branch (lines 188-191) ---
342342 it ( 'should return cached paginated data if available' , async ( ) => {
343343 const paginatedResult = { data : [ testEntity ] , count : 1 } ;
344- const cacheKey = 'testentity:pagination' ;
344+
345+ // ✅ Correct key format that includes skip and take
346+ const cacheKey = 'testentity0-2:pagination' ;
345347 mockCache . get . mockResolvedValue ( JSON . stringify ( paginatedResult ) ) ;
346348
347349 const result = await testService . findPaginated ( 0 , 2 ) ;
348350
349351 expect ( result ) . toEqual ( paginatedResult ) ;
350352 expect ( mockRepository . getEntitiesWithPagination ) . not . toHaveBeenCalled ( ) ;
353+
354+ // ✅ Expect the correct key
351355 expect ( logger . info ) . toHaveBeenCalledWith (
352356 expect . stringContaining (
353357 `Retrieved paginated data from cache: ${ cacheKey } ` ,
0 commit comments