Debian Codegraph @

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

raw
1 import { strict as assert } from 'assert';
2 import { SchemaFieldTypes } from '.';
3 import testUtils, { GLOBAL } from '../test-utils';
4 import { transformArguments } from './CURSOR_READ';
5
6 describe('CURSOR READ', () => {
7 describe('transformArguments', () => {
8 it('without options', () => {
9 assert.deepEqual(
10 transformArguments('index', 0),
11 ['FT.CURSOR', 'READ', 'index', '0']
12 );
13 });
14
15 it('with COUNT', () => {
16 assert.deepEqual(
17 transformArguments('index', 0, { COUNT: 1 }),
18 ['FT.CURSOR', 'READ', 'index', '0', 'COUNT', '1']
19 );
20 });
21 });
22
23 testUtils.testWithClient('client.ft.cursorRead', async client => {
24 const [, , { cursor }] = await Promise.all([
25 client.ft.create('idx', {
26 field: {
27 type: SchemaFieldTypes.TEXT
28 }
29 }),
30 client.hSet('key', 'field', 'value'),
31 client.ft.aggregateWithCursor('idx', '*', {
32 COUNT: 1
33 })
34 ]);
35
36 assert.deepEqual(
37 await client.ft.cursorRead('idx', cursor),
38 {
39 total: 0,
40 results: [],
41 cursor: 0
42 }
43 );
44 }, GLOBAL.SERVERS.OPEN);
45 });