1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

fix HGETALL spec

This commit is contained in:
dovi
2023-05-03 16:48:52 -04:00
parent 9177315667
commit 3bda368acb

View File

@@ -1,41 +1,35 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformReply } from './HGETALL';
describe('HGETALL', () => {
describe('transformReply', () => {
it('empty', () => {
assert.deepEqual(
transformReply([]),
Object.create(null)
);
});
it('with values', () => {
assert.deepEqual(
transformReply(['key1', 'value1', 'key2', 'value2']),
Object.create(null, {
key1: {
value: 'value1',
configurable: true,
enumerable: true,
writable: true
},
key2: {
value: 'value2',
configurable: true,
enumerable: true,
writable: true
}
})
);
});
});
testUtils.testAll('hGetAll empty', async client => {
assert.deepEqual(
await client.hGetAll('key'),
Object.create(null)
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
testUtils.testWithClient('client.hGetAll', async client => {
assert.deepEqual(
await client.hGetAll('key'),
Object.create(null)
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testAll('hGetAll with value', async client => {
const [, reply] = await Promise.all([
client.hSet('key', 'field', 'value'),
client.hGetAll('key')
]);
assert.deepEqual(
reply,
Object.create(null, {
field: {
value: 'value',
enumerable: true,
writable: true
}
})
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});