1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00

fix GEO* commands

This commit is contained in:
Leibale
2023-05-08 11:04:22 +03:00
parent d2e244a77d
commit 6a0b4db4f7
37 changed files with 1115 additions and 990 deletions

View File

@@ -1,31 +1,44 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { RedisCommandArguments } from '.';
import { GeoReplyWith } from './generic-transformers';
import { transformArguments } from './GEORADIUSBYMEMBER_WITH';
import GEORADIUSBYMEMBER_WITH from './GEORADIUSBYMEMBER_WITH';
import { CommandArguments } from '../RESP/types';
import { GEO_REPLY_WITH } from './GEOSEARCH_WITH';
describe('GEORADIUSBYMEMBER WITH', () => {
it('transformArguments', () => {
const expectedReply: RedisCommandArguments = ['GEORADIUSBYMEMBER', 'key', 'member', '3', 'm', 'WITHDIST'];
expectedReply.preserve = ['WITHDIST'];
it('transformArguments', () => {
const expectedReply: CommandArguments = ['GEORADIUSBYMEMBER', 'key', 'member', '3', 'm', 'WITHDIST'];
expectedReply.preserve = ['WITHDIST'];
assert.deepEqual(
transformArguments('key', 'member', 3 , 'm', [GeoReplyWith.DISTANCE]),
expectedReply
);
});
assert.deepEqual(
GEORADIUSBYMEMBER_WITH.transformArguments('key', 'member', 3, 'm', [
GEO_REPLY_WITH.DISTANCE
]),
expectedReply
);
});
testUtils.testWithClient('client.geoRadiusByMemberWith', async client => {
assert.deepEqual(
await client.geoRadiusByMemberWith('key', 'member', 3 , 'm', [GeoReplyWith.DISTANCE]),
[]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testAll('geoRadiusByMemberWith', async client => {
const [, reply] = await Promise.all([
client.geoAdd('key', {
member: 'member',
longitude: 1,
latitude: 2
}),
client.geoRadiusByMemberWith('key', 'member', 1, 'm', [
GEO_REPLY_WITH.HASH,
GEO_REPLY_WITH.DISTANCE,
GEO_REPLY_WITH.COORDINATES
])
]);
testUtils.testWithCluster('cluster.geoRadiusByMemberWith', async cluster => {
assert.deepEqual(
await cluster.geoRadiusByMemberWith('key', 'member', 3 , 'm', [GeoReplyWith.DISTANCE]),
[]
);
}, GLOBAL.CLUSTERS.OPEN);
assert.equal(reply.length, 1);
assert.equal(reply[0].member, 'member');
assert.equal(typeof reply[0].distance, 'string');
assert.equal(typeof reply[0].hash, 'number');
assert.equal(typeof reply[0].coordinates!.longitude, 'string');
assert.equal(typeof reply[0].coordinates!.latitude, 'string');
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});