@@ -17,7 +17,6 @@ const config = {
1717beforeEach ( async ( ) => {
1818 redisCache = cacheManager . caching ( {
1919 store : await redisStore ( config ) ,
20- ...config ,
2120 } ) ;
2221 await redisCache . reset ( ) ;
2322
@@ -35,7 +34,6 @@ beforeEach(async () => {
3534
3635 customRedisCache = cacheManager . caching ( {
3736 store : await redisStore ( customConfig ) ,
38- ...customConfig ,
3937 } ) ;
4038 await customRedisCache . reset ( ) ;
4139} ) ;
@@ -174,6 +172,13 @@ describe('del', () => {
174172 await expect ( redisCache . get ( 'foo' ) ) . resolves . toEqual ( null ) ;
175173 } ) ;
176174
175+ it ( 'should delete a value for a given key if options provided' , async ( ) => {
176+ await redisCache . set ( 'foo' , 'bar' ) ;
177+ await expect ( redisCache . get ( 'foo' ) ) . resolves . toEqual ( 'bar' ) ;
178+ await redisCache . del ( 'foo' , { } ) ;
179+ await expect ( redisCache . get ( 'foo' ) ) . resolves . toEqual ( null ) ;
180+ } ) ;
181+
177182 it ( 'should return an error if there is an error acquiring a connection' , async ( ) => {
178183 await redisCache . store . getClient ( ) . disconnect ( ) ;
179184 await expect ( redisCache . del ( 'foo' ) ) . rejects . toThrowError ( 'The client is closed' ) ;
@@ -328,13 +333,27 @@ describe('mdel', () => {
328333 await expect ( redisCache . mget ( 'foo' , 'foo2' ) ) . resolves . toEqual ( [ null , null ] ) ;
329334 } ) ;
330335
336+ it ( 'should delete a unlimited number of keys if options provided' , async ( ) => {
337+ await redisCache . mset ( 'foo' , 'bar' , 'foo2' , 'bar2' ) ;
338+ await expect ( redisCache . mget ( 'foo' , 'foo2' ) ) . resolves . toEqual ( [ 'bar' , 'bar2' ] ) ;
339+ await redisCache . store . mdel ( 'foo' , 'foo2' , { } ) ;
340+ await expect ( redisCache . mget ( 'foo' , 'foo2' ) ) . resolves . toEqual ( [ null , null ] ) ;
341+ } ) ;
342+
331343 it ( 'should delete an array of keys' , async ( ) => {
332344 await redisCache . mset ( 'foo' , 'bar' , 'foo2' , 'bar2' ) ;
333345 await expect ( redisCache . mget ( 'foo' , 'foo2' ) ) . resolves . toEqual ( [ 'bar' , 'bar2' ] ) ;
334346 await redisCache . store . mdel ( [ 'foo' , 'foo2' ] ) ;
335347 await expect ( redisCache . mget ( 'foo' , 'foo2' ) ) . resolves . toEqual ( [ null , null ] ) ;
336348 } ) ;
337349
350+ it ( 'should delete an array of keys if options provided' , async ( ) => {
351+ await redisCache . mset ( 'foo' , 'bar' , 'foo2' , 'bar2' ) ;
352+ await expect ( redisCache . mget ( 'foo' , 'foo2' ) ) . resolves . toEqual ( [ 'bar' , 'bar2' ] ) ;
353+ await redisCache . store . mdel ( [ 'foo' , 'foo2' ] , { } ) ;
354+ await expect ( redisCache . mget ( 'foo' , 'foo2' ) ) . resolves . toEqual ( [ null , null ] ) ;
355+ } ) ;
356+
338357 it ( 'should return an error if there is an error acquiring a connection' , async ( ) => {
339358 await redisCache . store . getClient ( ) . disconnect ( ) ;
340359 await expect ( redisCache . store . mdel ( 'foo' ) ) . rejects . toThrowError ( 'The client is closed' ) ;
0 commit comments