@@ -10,53 +10,53 @@ describe('Redis', () => {
1010 describe ( 'getCacheKeySafely (single arg)' , ( ) => {
1111 it ( 'should return an empty string if there are no command arguments' , ( ) => {
1212 const result = getCacheKeySafely ( 'get' , [ ] ) ;
13- expect ( result ) . toBe ( '' ) ;
13+ expect ( result ) . toBe ( undefined ) ;
1414 } ) ;
1515
1616 it ( 'should return a string representation of a single argument' , ( ) => {
1717 const cmdArgs = [ 'key1' ] ;
1818 const result = getCacheKeySafely ( 'get' , cmdArgs ) ;
19- expect ( result ) . toBe ( 'key1' ) ;
19+ expect ( result ) . toStrictEqual ( [ 'key1' ] ) ;
2020 } ) ;
2121
2222 it ( 'should return only the key for multiple arguments' , ( ) => {
2323 const cmdArgs = [ 'key1' , 'the-value' ] ;
2424 const result = getCacheKeySafely ( 'get' , cmdArgs ) ;
25- expect ( result ) . toBe ( 'key1' ) ;
25+ expect ( result ) . toStrictEqual ( [ 'key1' ] ) ;
2626 } ) ;
2727
2828 it ( 'should handle number arguments' , ( ) => {
2929 const cmdArgs = [ 1 , 'the-value' ] ;
3030 const result = getCacheKeySafely ( 'get' , cmdArgs ) ;
31- expect ( result ) . toBe ( '1' ) ;
31+ expect ( result ) . toStrictEqual ( [ '1' ] ) ;
3232 } ) ;
3333
3434 it ( 'should handle Buffer arguments' , ( ) => {
3535 const cmdArgs = [ Buffer . from ( 'key1' ) , Buffer . from ( 'key2' ) ] ;
3636 const result = getCacheKeySafely ( 'get' , cmdArgs ) ;
37- expect ( result ) . toBe ( 'key1' ) ;
37+ expect ( result ) . toStrictEqual ( [ 'key1' ] ) ;
3838 } ) ;
3939
4040 it ( 'should return <unknown> if the arg type is not supported' , ( ) => {
4141 const cmdArgs = [ Symbol ( 'key1' ) ] ;
4242 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4343 // @ts -ignore
4444 const result = getCacheKeySafely ( 'get' , cmdArgs ) ;
45- expect ( result ) . toBe ( '<unknown>' ) ;
45+ expect ( result ) . toStrictEqual ( [ '<unknown>' ] ) ;
4646 } ) ;
4747 } ) ;
4848
4949 describe ( 'getCacheKeySafely (multiple args)' , ( ) => {
5050 it ( 'should return a comma-separated string for multiple arguments with mget command' , ( ) => {
5151 const cmdArgs = [ 'key1' , 'key2' , 'key3' ] ;
5252 const result = getCacheKeySafely ( 'mget' , cmdArgs ) ;
53- expect ( result ) . toBe ( 'key1, key2, key3' ) ;
53+ expect ( result ) . toStrictEqual ( [ 'key1' , ' key2' , ' key3'] ) ;
5454 } ) ;
5555
5656 it ( 'should handle Buffer arguments' , ( ) => {
5757 const cmdArgs = [ Buffer . from ( 'key1' ) , Buffer . from ( 'key2' ) ] ;
5858 const result = getCacheKeySafely ( 'mget' , cmdArgs ) ;
59- expect ( result ) . toBe ( 'key1, key2' ) ;
59+ expect ( result ) . toStrictEqual ( [ 'key1' , ' key2'] ) ;
6060 } ) ;
6161
6262 it ( 'should handle array arguments' , ( ) => {
@@ -65,13 +65,13 @@ describe('Redis', () => {
6565 [ 'key3' , 'key4' ] ,
6666 ] ;
6767 const result = getCacheKeySafely ( 'mget' , cmdArgs ) ;
68- expect ( result ) . toBe ( 'key1, key2, key3, key4' ) ;
68+ expect ( result ) . toStrictEqual ( [ 'key1' , ' key2' , ' key3' , ' key4'] ) ;
6969 } ) ;
7070
7171 it ( 'should handle mixed type arguments' , ( ) => {
7272 const cmdArgs = [ Buffer . from ( 'key1' ) , [ 'key2' , 'key3' ] , [ Buffer . from ( 'key4' ) , 'key5' , 'key6' , 7 , [ 'key8' ] ] ] ;
7373 const result = getCacheKeySafely ( 'mget' , cmdArgs ) ;
74- expect ( result ) . toBe ( 'key1, key2, key3, key4, key5, key6, 7, key8' ) ;
74+ expect ( result ) . toStrictEqual ( [ 'key1' , ' key2' , ' key3' , ' key4' , ' key5' , ' key6' , '7' , ' key8'] ) ;
7575 } ) ;
7676
7777 it ( 'should handle nested arrays with mixed types in arguments' , ( ) => {
@@ -80,15 +80,15 @@ describe('Redis', () => {
8080 [ 'key3' , 'key4' , [ Buffer . from ( 'key5' ) , [ 'key6' ] ] ] ,
8181 ] ;
8282 const result = getCacheKeySafely ( 'mget' , cmdArgs ) ;
83- expect ( result ) . toBe ( 'key1, key2, key3, key4, key5, key6' ) ;
83+ expect ( result ) . toStrictEqual ( [ 'key1' , ' key2' , ' key3' , ' key4' , ' key5' , ' key6'] ) ;
8484 } ) ;
8585
8686 it ( 'should return <unknown> if the arg type is not supported' , ( ) => {
8787 const cmdArgs = [ Symbol ( 'key1' ) ] ;
8888 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8989 // @ts -ignore
9090 const result = getCacheKeySafely ( 'mget' , cmdArgs ) ;
91- expect ( result ) . toBe ( '<unknown>' ) ;
91+ expect ( result ) . toStrictEqual ( [ '<unknown>' ] ) ;
9292 } ) ;
9393 } ) ;
9494
@@ -137,7 +137,7 @@ describe('Redis', () => {
137137 it ( 'should return false for non-cache commands' , ( ) => {
138138 const command = 'EXISTS' ;
139139 const commandLowercase = 'exists' ;
140- const key = 'cache:test-key' ;
140+ const key = [ 'cache:test-key' ] ;
141141 const result1 = shouldConsiderForCache ( command , key , prefixes ) ;
142142 const result2 = shouldConsiderForCache ( commandLowercase , key , prefixes ) ;
143143 expect ( result1 ) . toBe ( false ) ;
@@ -146,35 +146,35 @@ describe('Redis', () => {
146146
147147 it ( 'should return true for cache commands with matching prefix' , ( ) => {
148148 const command = 'get' ;
149- const key = 'cache:test-key' ;
149+ const key = [ 'cache:test-key' ] ;
150150 const result = shouldConsiderForCache ( command , key , prefixes ) ;
151151 expect ( result ) . toBe ( true ) ;
152152 } ) ;
153153
154154 it ( 'should return false for cache commands without matching prefix' , ( ) => {
155155 const command = 'get' ;
156- const key = 'test-key' ;
156+ const key = [ 'test-key' ] ;
157157 const result = shouldConsiderForCache ( command , key , prefixes ) ;
158158 expect ( result ) . toBe ( false ) ;
159159 } ) ;
160160
161161 it ( 'should return true for multiple keys with at least one matching prefix' , ( ) => {
162162 const command = 'mget' ;
163- const key = 'test-key, cache:test-key' ;
163+ const key = [ 'test-key' , ' cache:test-key'] ;
164164 const result = shouldConsiderForCache ( command , key , prefixes ) ;
165165 expect ( result ) . toBe ( true ) ;
166166 } ) ;
167167
168168 it ( 'should return false for multiple keys without any matching prefix' , ( ) => {
169169 const command = 'mget' ;
170- const key = 'test-key, test-key2' ;
170+ const key = [ 'test-key' , ' test-key2'] ;
171171 const result = shouldConsiderForCache ( command , key , prefixes ) ;
172172 expect ( result ) . toBe ( false ) ;
173173 } ) ;
174174
175175 GET_COMMANDS . concat ( SET_COMMANDS ) . forEach ( command => {
176176 it ( `should return true for ${ command } command with matching prefix` , ( ) => {
177- const key = 'cache:test-key' ;
177+ const key = [ 'cache:test-key' ] ;
178178 const result = shouldConsiderForCache ( command , key , prefixes ) ;
179179 expect ( result ) . toBe ( true ) ;
180180 } ) ;
0 commit comments