Debian Codegraph @

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

raw
1 import { strict as assert } from 'assert';
2 import testUtils, { GLOBAL } from '../test-utils';
3 import { transformArguments } from './SUGGET';
4
5 describe('SUGGET', () => {
6 describe('transformArguments', () => {
7 it('without options', () => {
8 assert.deepEqual(
9 transformArguments('key', 'prefix'),
10 ['FT.SUGGET', 'key', 'prefix']
11 );
12 });
13
14 it('with FUZZY', () => {
15 assert.deepEqual(
16 transformArguments('key', 'prefix', { FUZZY: true }),
17 ['FT.SUGGET', 'key', 'prefix', 'FUZZY']
18 );
19 });
20
21 it('with MAX', () => {
22 assert.deepEqual(
23 transformArguments('key', 'prefix', { MAX: 10 }),
24 ['FT.SUGGET', 'key', 'prefix', 'MAX', '10']
25 );
26 });
27 });
28
29 describe('client.ft.sugGet', () => {
30 testUtils.testWithClient('null', async client => {
31 assert.equal(
32 await client.ft.sugGet('key', 'prefix'),
33 null
34 );
35 }, GLOBAL.SERVERS.OPEN);
36
37 testUtils.testWithClient('with suggestions', async client => {
38 await client.ft.sugAdd('key', 'string', 1);
39
40 assert.deepEqual(
41 await client.ft.sugGet('key', 'string'),
42 ['string']
43 );
44 }, GLOBAL.SERVERS.OPEN);
45 });
46 });