1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

more commands

This commit is contained in:
dovi
2023-07-10 12:29:36 -04:00
parent 9915d67510
commit d2b0b4e5b0
12 changed files with 196 additions and 156 deletions

View File

@@ -1,37 +1,37 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ARRINDEX';
import ARRINDEX from './ARRINDEX';
describe('ARRINDEX', () => {
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments('key', '$', 'json'),
['JSON.ARRINDEX', 'key', '$', '"json"']
);
});
it('with start', () => {
assert.deepEqual(
transformArguments('key', '$', 'json', 1),
['JSON.ARRINDEX', 'key', '$', '"json"', '1']
);
});
it('with start, end', () => {
assert.deepEqual(
transformArguments('key', '$', 'json', 1, 2),
['JSON.ARRINDEX', 'key', '$', '"json"', '1', '2']
);
});
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
ARRINDEX.transformArguments('key', '$', 'json'),
['JSON.ARRINDEX', 'key', '$', '"json"']
);
});
testUtils.testWithClient('client.json.arrIndex', async client => {
await client.json.set('key', '$', []);
it('with start', () => {
assert.deepEqual(
ARRINDEX.transformArguments('key', '$', 'json', 1),
['JSON.ARRINDEX', 'key', '$', '"json"', '1']
);
});
assert.deepEqual(
await client.json.arrIndex('key', '$', 'json'),
[-1]
);
}, GLOBAL.SERVERS.OPEN);
it('with start, end', () => {
assert.deepEqual(
ARRINDEX.transformArguments('key', '$', 'json', 1, 2),
['JSON.ARRINDEX', 'key', '$', '"json"', '1', '2']
);
});
});
testUtils.testWithClient('client.json.arrIndex', async client => {
await client.json.set('key', '$', []);
assert.deepEqual(
await client.json.arrIndex('key', '$', 'json'),
[-1]
);
}, GLOBAL.SERVERS.OPEN);
});