You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
* Support the NOVALUES option of HSCAN Issue #2705 The NOVALUES option instructs HSCAN to only return keys, without their values. This is materialized as a new command, `hScanNoValues`, given that the return type is different from the usual return type of `hScan`. Also a new iterator is provided, `hScanNoValuesIterator`, for the same reason. * skip hscan novalues test if redis < 7.4 * Also don't test hscan no values iterator < 7.4 --------- Co-authored-by: Shaya Potter <spotter@gmail.com>
91 lines
2.4 KiB
TypeScript
91 lines
2.4 KiB
TypeScript
import { strict as assert } from 'assert';
|
|
import testUtils, { GLOBAL } from '../test-utils';
|
|
import { transformArguments, transformReply } from './HSCAN';
|
|
|
|
describe('HSCAN', () => {
|
|
describe('transformArguments', () => {
|
|
it('cusror only', () => {
|
|
assert.deepEqual(
|
|
transformArguments('key', 0),
|
|
['HSCAN', 'key', '0']
|
|
);
|
|
});
|
|
|
|
it('with MATCH', () => {
|
|
assert.deepEqual(
|
|
transformArguments('key', 0, {
|
|
MATCH: 'pattern'
|
|
}),
|
|
['HSCAN', 'key', '0', 'MATCH', 'pattern']
|
|
);
|
|
});
|
|
|
|
it('with COUNT', () => {
|
|
assert.deepEqual(
|
|
transformArguments('key', 0, {
|
|
COUNT: 1
|
|
}),
|
|
['HSCAN', 'key', '0', 'COUNT', '1']
|
|
);
|
|
});
|
|
|
|
it('with MATCH & COUNT', () => {
|
|
assert.deepEqual(
|
|
transformArguments('key', 0, {
|
|
MATCH: 'pattern',
|
|
COUNT: 1
|
|
}),
|
|
['HSCAN', 'key', '0', 'MATCH', 'pattern', 'COUNT', '1']
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('transformReply', () => {
|
|
it('without tuples', () => {
|
|
assert.deepEqual(
|
|
transformReply(['0', []]),
|
|
{
|
|
cursor: 0,
|
|
tuples: []
|
|
}
|
|
);
|
|
});
|
|
|
|
it('with tuples', () => {
|
|
assert.deepEqual(
|
|
transformReply(['0', ['field', 'value']]),
|
|
{
|
|
cursor: 0,
|
|
tuples: [{
|
|
field: 'field',
|
|
value: 'value'
|
|
}]
|
|
}
|
|
);
|
|
});
|
|
});
|
|
|
|
testUtils.testWithClient('client.hScan', async client => {
|
|
assert.deepEqual(
|
|
await client.hScan('key', 0),
|
|
{
|
|
cursor: 0,
|
|
tuples: []
|
|
}
|
|
);
|
|
|
|
await Promise.all([
|
|
client.hSet('key', 'a', '1'),
|
|
client.hSet('key', 'b', '2')
|
|
]);
|
|
|
|
assert.deepEqual(
|
|
await client.hScan('key', 0),
|
|
{
|
|
cursor: 0,
|
|
tuples: [{field: 'a', value: '1'}, {field: 'b', value: '2'}]
|
|
}
|
|
);
|
|
}, GLOBAL.SERVERS.OPEN);
|
|
});
|