Debian Codegraph @

packages/search/lib/commands/AGGREGATE_WITHCURSOR.spec.ts

raw
1 import { strict as assert } from 'assert';
2 import testUtils, { GLOBAL } from '../test-utils';
3 import { transformArguments } from './AGGREGATE_WITHCURSOR';
4 import { SchemaFieldTypes } from '.';
5
6 describe('AGGREGATE WITHCURSOR', () => {
7 describe('transformArguments', () => {
8 it('without options', () => {
9 assert.deepEqual(
10 transformArguments('index', '*'),
11 ['FT.AGGREGATE', 'index', '*', 'WITHCURSOR']
12 );
13 });
14
15 it('with COUNT', () => {
16 assert.deepEqual(
17 transformArguments('index', '*', { COUNT: 1 }),
18 ['FT.AGGREGATE', 'index', '*', 'WITHCURSOR', 'COUNT', '1']
19 );
20 });
21 });
22
23 testUtils.testWithClient('client.ft.aggregateWithCursor', async client => {
24 await client.ft.create('index', {
25 field: SchemaFieldTypes.NUMERIC
26 });
27
28 assert.deepEqual(
29 await client.ft.aggregateWithCursor('index', '*'),
30 {
31 total: 0,
32 results: [],
33 cursor: 0
34 }
35 );
36 }, GLOBAL.SERVERS.OPEN);
37 });