1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00
Files
node-redis/packages/search/lib/commands/AGGREGATE_WITHCURSOR.spec.ts
Hristo Temelski 1af01373db feat(search): Set default dialect to 2 for Redis Search commands (#2895)
- The default dialect `DEFAULT_DIALECT`  is now set to '2'
- Automatically append DIALECT parameter to search commands when not explicitly specified
2025-02-17 13:47:12 +02:00

50 lines
1.4 KiB
TypeScript

import { strict as assert } from 'node:assert';
import testUtils, { GLOBAL } from '../test-utils';
import AGGREGATE_WITHCURSOR from './AGGREGATE_WITHCURSOR';
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
import { DEFAULT_DIALECT } from '../dialect/default';
describe('AGGREGATE WITHCURSOR', () => {
describe('transformArguments', () => {
it('without options', () => {
assert.deepEqual(
parseArgs(AGGREGATE_WITHCURSOR, 'index', '*'),
['FT.AGGREGATE', 'index', '*', 'DIALECT', DEFAULT_DIALECT, 'WITHCURSOR']
);
});
it('with COUNT', () => {
assert.deepEqual(
parseArgs(AGGREGATE_WITHCURSOR, 'index', '*', {
COUNT: 1
}),
['FT.AGGREGATE', 'index', '*', 'DIALECT', DEFAULT_DIALECT, 'WITHCURSOR', 'COUNT', '1']
);
});
it('with MAXIDLE', () => {
assert.deepEqual(
parseArgs(AGGREGATE_WITHCURSOR, 'index', '*', {
MAXIDLE: 1
}),
['FT.AGGREGATE', 'index', '*', 'DIALECT', DEFAULT_DIALECT, 'WITHCURSOR', 'MAXIDLE', '1']
);
});
});
testUtils.testWithClient('client.ft.aggregateWithCursor', async client => {
await client.ft.create('index', {
field: 'NUMERIC'
});
assert.deepEqual(
await client.ft.aggregateWithCursor('index', '*'),
{
total: 0,
results: [],
cursor: 0
}
);
}, GLOBAL.SERVERS.OPEN);
});