| 1 |
import { strict as assert } from 'assert'; |
| 2 |
import testUtils, { GLOBAL } from '../test-utils'; |
| 3 |
import { transformArguments } from './SUGGET_WITHSCORES'; |
| 4 |
|
| 5 |
describe('SUGGET WITHSCORES', () => { |
| 6 |
it('transformArguments', () => { |
| 7 |
assert.deepEqual( |
| 8 |
transformArguments('key', 'prefix'), |
| 9 |
['FT.SUGGET', 'key', 'prefix', 'WITHSCORES'] |
| 10 |
); |
| 11 |
}); |
| 12 |
|
| 13 |
describe('client.ft.sugGetWithScores', () => { |
| 14 |
testUtils.testWithClient('null', async client => { |
| 15 |
assert.equal( |
| 16 |
await client.ft.sugGetWithScores('key', 'prefix'), |
| 17 |
null |
| 18 |
); |
| 19 |
}, GLOBAL.SERVERS.OPEN); |
| 20 |
|
| 21 |
testUtils.testWithClient('with suggestions', async client => { |
| 22 |
await client.ft.sugAdd('key', 'string', 1); |
| 23 |
|
| 24 |
assert.deepEqual( |
| 25 |
await client.ft.sugGetWithScores('key', 'string'), |
| 26 |
[{ |
| 27 |
suggestion: 'string', |
| 28 |
score: 2147483648 |
| 29 |
}] |
| 30 |
); |
| 31 |
}, GLOBAL.SERVERS.OPEN); |
| 32 |
}); |
| 33 |
}); |