| 1 |
import { strict as assert } from 'assert'; |
| 2 |
import testUtils, { GLOBAL } from '../test-utils'; |
| 3 |
import { SchemaFieldTypes } from '.'; |
| 4 |
import { transformArguments } from './PROFILE_SEARCH'; |
| 5 |
|
| 6 |
describe('PROFILE SEARCH', () => { |
| 7 |
describe('transformArguments', () => { |
| 8 |
it('without options', () => { |
| 9 |
assert.deepEqual( |
| 10 |
transformArguments('index', 'query'), |
| 11 |
['FT.PROFILE', 'index', 'SEARCH', 'QUERY', 'query'] |
| 12 |
); |
| 13 |
}); |
| 14 |
|
| 15 |
it('with options', () => { |
| 16 |
assert.deepEqual( |
| 17 |
transformArguments('index', 'query', { |
| 18 |
LIMITED: true, |
| 19 |
VERBATIM: true, |
| 20 |
INKEYS: 'key' |
| 21 |
}), |
| 22 |
['FT.PROFILE', 'index', 'SEARCH', 'LIMITED', 'QUERY', 'query', |
| 23 |
'VERBATIM', 'INKEYS', '1', 'key'] |
| 24 |
); |
| 25 |
}); |
| 26 |
}); |
| 27 |
|
| 28 |
testUtils.testWithClient('client.ft.search', async client => { |
| 29 |
await Promise.all([ |
| 30 |
client.ft.create('index', { |
| 31 |
field: SchemaFieldTypes.NUMERIC |
| 32 |
}), |
| 33 |
client.hSet('1', 'field', '1') |
| 34 |
]); |
| 35 |
|
| 36 |
const res = await client.ft.profileSearch('index', '*'); |
| 37 |
assert.ok(typeof res.profile.iteratorsProfile.counter === 'number'); |
| 38 |
assert.ok(typeof res.profile.parsingTime === 'string'); |
| 39 |
assert.ok(res.results.total == 1); |
| 40 |
}, GLOBAL.SERVERS.OPEN); |
| 41 |
}); |