Skip to content

Commit 53f0a29

Browse files
committed
use transformJsonReply
1 parent b1a321e commit 53f0a29

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

packages/client/lib/commands/VGETATTR.spec.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ describe('VGETATTR', () => {
2020
await client.vSetAttr('key', 'element', { name: 'test' });
2121

2222
const result = await client.vGetAttr('key', 'element');
23+
2324
assert.ok(result !== null);
25+
assert.equal(typeof result, 'object')
26+
27+
assert.deepEqual(result, {
28+
name: 'test'
29+
})
30+
2431

2532
}, {
2633
client: GLOBAL.SERVERS.OPEN,
@@ -48,13 +55,16 @@ describe('VGETATTR', () => {
4855
const result = await client.vGetAttr('resp3-key', 'resp3-element');
4956

5057
assert.ok(result !== null);
58+
assert.equal(typeof result, 'object')
59+
60+
assert.deepEqual(result, {
61+
name: 'test-item',
62+
category: 'electronics',
63+
price: 99.99,
64+
inStock: true,
65+
tags: ['new', 'featured']
66+
})
5167

52-
// Parse the JSON result and verify structure
53-
const parsedAttrs = JSON.parse(result.toString());
54-
assert.equal(parsedAttrs.name, 'test-item');
55-
assert.equal(parsedAttrs.price, 99.99);
56-
assert.equal(parsedAttrs.inStock, true);
57-
assert.ok(Array.isArray(parsedAttrs.tags));
5868
}, {
5969
...GLOBAL.SERVERS.OPEN,
6070
clientOptions: {

packages/client/lib/commands/VGETATTR.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { CommandParser } from '../client/parser';
2-
import { RedisArgument, BlobStringReply, NullReply, Command } from '../RESP/types';
2+
import { RedisArgument, Command } from '../RESP/types';
3+
import { transformRedisJsonNullReply } from './generic-transformers';
34

45
export default {
56
CACHEABLE: true,
@@ -17,5 +18,5 @@ export default {
1718
parser.pushKey(key);
1819
parser.push(element);
1920
},
20-
transformReply: undefined as unknown as () => BlobStringReply | NullReply
21+
transformReply: transformRedisJsonNullReply
2122
} as const satisfies Command;

0 commit comments

Comments
 (0)