diff --git a/docs/scan-iterators.md b/docs/scan-iterators.md index f8e317fcef..ead3a346a2 100644 --- a/docs/scan-iterators.md +++ b/docs/scan-iterators.md @@ -22,7 +22,7 @@ You can override the default options by providing a configuration object: ```typescript client.scanIterator({ - cursor: 0, // 0 by default + cursor: '0', // optional, defaults to '0' TYPE: 'string', // `SCAN` only MATCH: 'patter*', COUNT: 100 diff --git a/packages/client/lib/client/index.spec.ts b/packages/client/lib/client/index.spec.ts index 5efcdb2aa0..0312aa9d0c 100644 --- a/packages/client/lib/client/index.spec.ts +++ b/packages/client/lib/client/index.spec.ts @@ -437,19 +437,21 @@ describe('Client', () => { // }, GLOBAL.SERVERS.OPEN); testUtils.testWithClient('scanIterator', async client => { - const promises = [], - keys = new Set(); + const entries: Array = [], + keys = new Set(); for (let i = 0; i < 100; i++) { const key = i.toString(); keys.add(key); - promises.push(client.set(key, '')); + entries.push(key, ''); } - await Promise.all(promises); + await client.mSet(entries); const results = new Set(); for await (const keys of client.scanIterator()) { - results.add(...keys); + for (const key of keys) { + results.add(key); + } } assert.deepEqual(keys, results); @@ -465,7 +467,7 @@ describe('Client', () => { const results: Record = {}; for await (const entries of client.hScanIterator('key')) { - for (const [field, value] of entries) { + for (const { field, value } of entries) { results[field] = value; } } @@ -512,7 +514,7 @@ describe('Client', () => { } } - assert.deepEqual(members, results); + assert.deepEqual(map, results); }, GLOBAL.SERVERS.OPEN); // describe('PubSub', () => {