| 1 | import { strict as assert } from 'assert'; |
| 2 | import testUtils, { GLOBAL } from '../../test-utils'; |
| 3 | import { transformArguments } from './LIST_WITHCOUNT'; |
| 4 | |
| 5 | describe('TOPK LIST WITHCOUNT', () => { |
| 6 | testUtils.isVersionGreaterThanHook([2, 2, 9]); |
| 7 | |
| 8 | it('transformArguments', () => { |
| 9 | assert.deepEqual( |
| 10 | transformArguments('key'), |
| 11 | ['TOPK.LIST', 'key', 'WITHCOUNT'] |
| 12 | ); |
| 13 | }); |
| 14 | |
| 15 | testUtils.testWithClient('client.topK.listWithCount', async client => { |
| 16 | const [,, list] = await Promise.all([ |
| 17 | client.topK.reserve('key', 3), |
| 18 | client.topK.add('key', 'item'), |
| 19 | client.topK.listWithCount('key') |
| 20 | ]); |
| 21 | |
| 22 | assert.deepEqual( |
| 23 | list, |
| 24 | [{ |
| 25 | item: 'item', |
| 26 | count: 1 |
| 27 | }] |
| 28 | ); |
| 29 | }, GLOBAL.SERVERS.OPEN); |
| 30 | }); |