@@ -3,21 +3,55 @@ import testUtils, { GLOBAL } from '../test-utils';
33import { parseArgs } from './generic-transformers' ;
44import GET from './GET' ;
55
6- describe ( 'GET' , ( ) => {
7- it ( 'transformArguments' , ( ) => {
8- assert . deepEqual (
9- parseArgs ( GET , 'key' ) ,
10- [ 'GET' , 'key' ]
11- ) ;
6+ describe ( 'GET Command' , ( ) => {
7+
8+ describe ( 'transformArguments' , ( ) => {
9+ it ( 'should build correct Redis command' , ( ) => {
10+ assert . deepEqual ( parseArgs ( GET , 'my-key' ) , [ 'GET' , 'my-key' ] ) ;
11+ assert . deepEqual ( parseArgs ( GET , '' ) , [ 'GET' , '' ] ) ;
12+
13+
14+ const binaryKey = Buffer . from ( 'binary-key' ) ;
15+ assert . deepEqual ( parseArgs ( GET , binaryKey ) , [ 'GET' , binaryKey ] ) ;
16+ } ) ;
1217 } ) ;
1318
14- testUtils . testAll ( 'get' , async client => {
15- assert . equal (
16- await client . get ( 'key' ) ,
17- null
18- ) ;
19- } , {
20- client : GLOBAL . SERVERS . OPEN ,
21- cluster : GLOBAL . CLUSTERS . OPEN
19+ describe ( 'transformReply' , ( ) => {
20+ testUtils . testAll ( 'get' , async client => {
21+
22+ const missing = await client . get ( 'nonexistent' ) ;
23+ assert . equal ( missing , null , 'Should return null for missing keys' ) ;
24+
25+
26+ await client . set ( 'string-key' , 'hello' ) ;
27+ const stringVal = await client . get ( 'string-key' ) ;
28+ assert . equal ( stringVal , 'hello' , 'Should return string value' ) ;
29+
30+
31+ await client . set ( 'num-key' , '123' ) ;
32+ const numVal = await client . get ( 'num-key' ) ;
33+ assert . equal ( numVal , '123' , 'Should return numeric string as string' ) ;
34+
35+
36+ await client . set ( 'buffer-key' , Buffer . from ( 'buffered' ) ) ;
37+ const bufferVal = await client . get ( 'buffer-key' ) ;
38+ assert . equal ( typeof bufferVal , 'string' , 'Should return a string even if input was buffer' ) ;
39+ assert . equal ( bufferVal , 'buffered' , 'Should convert buffer to string' ) ;
40+
41+
42+ await client . set ( 'empty-key' , '' ) ;
43+ const emptyVal = await client . get ( 'empty-key' ) ;
44+ assert . equal ( emptyVal , '' , 'Should handle empty string values' ) ;
45+
46+
47+ await client . set ( 'overwrite-key' , 'first' ) ;
48+ await client . set ( 'overwrite-key' , 'second' ) ;
49+ const overwriteVal = await client . get ( 'overwrite-key' ) ;
50+ assert . equal ( overwriteVal , 'second' , 'Should return updated value' ) ;
51+
52+ } , {
53+ client : GLOBAL . SERVERS . OPEN ,
54+ cluster : GLOBAL . CLUSTERS . OPEN ,
55+ } ) ;
2256 } ) ;
23- } ) ;
57+ } ) ;
0 commit comments