| 1 |
import { strict as assert } from 'assert'; |
| 2 |
import testUtils, { GLOBAL } from '../test-utils'; |
| 3 |
import { transformArguments } from './SYNUPDATE'; |
| 4 |
import { SchemaFieldTypes } from '.'; |
| 5 |
|
| 6 |
describe('SYNUPDATE', () => { |
| 7 |
describe('transformArguments', () => { |
| 8 |
it('single term', () => { |
| 9 |
assert.deepEqual( |
| 10 |
transformArguments('index', 'groupId', 'term'), |
| 11 |
['FT.SYNUPDATE', 'index', 'groupId', 'term'] |
| 12 |
); |
| 13 |
}); |
| 14 |
|
| 15 |
it('multiple terms', () => { |
| 16 |
assert.deepEqual( |
| 17 |
transformArguments('index', 'groupId', ['1', '2']), |
| 18 |
['FT.SYNUPDATE', 'index', 'groupId', '1', '2'] |
| 19 |
); |
| 20 |
}); |
| 21 |
|
| 22 |
it('with SKIPINITIALSCAN', () => { |
| 23 |
assert.deepEqual( |
| 24 |
transformArguments('index', 'groupId', 'term', { SKIPINITIALSCAN: true }), |
| 25 |
['FT.SYNUPDATE', 'index', 'groupId', 'SKIPINITIALSCAN', 'term'] |
| 26 |
); |
| 27 |
}); |
| 28 |
}); |
| 29 |
|
| 30 |
testUtils.testWithClient('client.ft.synUpdate', async client => { |
| 31 |
await client.ft.create('index', { |
| 32 |
field: SchemaFieldTypes.TEXT |
| 33 |
}); |
| 34 |
|
| 35 |
assert.equal( |
| 36 |
await client.ft.synUpdate('index', 'groupId', 'term'), |
| 37 |
'OK' |
| 38 |
); |
| 39 |
}, GLOBAL.SERVERS.OPEN); |
| 40 |
}); |