1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-03 04:01:40 +03:00
Files
node-redis/packages/client/lib/commands/HGETDEL.spec.ts
Hristo Temelski 4cbecf6a09 feat(hash field expiration): Added hash field expiration commands (#2907)
* [CAE-686] Added hash field expiration commands

* [CAE-686] Improve HSETEX return type

* [CAE-686] Minor pushTuples change, renamed HSETEX test

* [CAE-686] Changed hsetex function signature for better consistency with other commands

* [CAE-686] Fixed hsetex test

* [CAE-686] Bumped docker version to 8.0-M05-pre, enabled and fixed tests
2025-03-19 12:26:23 +02:00

49 lines
1.6 KiB
TypeScript

import { strict as assert } from 'node:assert';
import testUtils, { GLOBAL } from '../test-utils';
import { BasicCommandParser } from '../client/parser';
import HGETDEL from './HGETDEL';
describe('HGETDEL parseCommand', () => {
it('hGetDel parseCommand base', () => {
const parser = new BasicCommandParser;
HGETDEL.parseCommand(parser, 'key', 'field');
assert.deepEqual(parser.redisArgs, ['HGETDEL', 'key', 'FIELDS', '1', 'field']);
});
it('hGetDel parseCommand variadic', () => {
const parser = new BasicCommandParser;
HGETDEL.parseCommand(parser, 'key', ['field1', 'field2']);
assert.deepEqual(parser.redisArgs, ['HGETDEL', 'key', 'FIELDS', '2', 'field1', 'field2']);
});
});
describe('HGETDEL call', () => {
testUtils.testWithClientIfVersionWithinRange([[8], 'LATEST'], 'hGetDel empty single field', async client => {
assert.deepEqual(
await client.hGetDel('key', 'filed1'),
[null]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClientIfVersionWithinRange([[8], 'LATEST'], 'hGetDel empty multiple fields', async client => {
assert.deepEqual(
await client.hGetDel('key', ['filed1', 'field2']),
[null, null]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClientIfVersionWithinRange([[8], 'LATEST'], 'hGetDel partially populated multiple fields', async client => {
await client.hSet('key', 'field1', 'value1')
assert.deepEqual(
await client.hGetDel('key', ['field1', 'field2']),
['value1', null]
);
assert.deepEqual(
await client.hGetDel('key', 'field1'),
[null]
);
}, GLOBAL.SERVERS.OPEN);
});