You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-03 04:01:40 +03:00
* fix: fix various command import issues there was some sort of a circular dependency in <module>/lib/commands/index.ts for various modules fixes #2937 fixes #2941 * remove redundant definition
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { strict as assert } from 'node:assert';
|
|
import testUtils, { GLOBAL } from '../test-utils';
|
|
import GET from './GET';
|
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
|
|
|
describe('JSON.GET', () => {
|
|
describe('transformArguments', () => {
|
|
it('simple', () => {
|
|
assert.deepEqual(
|
|
parseArgs(GET, 'key'),
|
|
['JSON.GET', 'key']
|
|
);
|
|
});
|
|
|
|
describe('with path', () => {
|
|
it('string', () => {
|
|
assert.deepEqual(
|
|
parseArgs(GET, 'key', { path: '$' }),
|
|
['JSON.GET', 'key', '$']
|
|
);
|
|
});
|
|
|
|
it('array', () => {
|
|
assert.deepEqual(
|
|
parseArgs(GET, 'key', { path: ['$.1', '$.2'] }),
|
|
['JSON.GET', 'key', '$.1', '$.2']
|
|
);
|
|
});
|
|
});
|
|
});
|
|
|
|
testUtils.testWithClient('client.json.get', async client => {
|
|
assert.equal(
|
|
await client.json.get('key'),
|
|
null
|
|
);
|
|
|
|
await client.json.set('noderedis:users:1', '$', { name: 'Alice', age: 32, })
|
|
const res = await client.json.get('noderedis:users:1');
|
|
assert.equal(typeof res, 'object')
|
|
assert.deepEqual(res, { name: 'Alice', age: 32, })
|
|
|
|
}, GLOBAL.SERVERS.OPEN);
|
|
});
|