You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
V5 bringing RESP3, Sentinel and TypeMapping to node-redis
RESP3 Support - Some commands responses in RESP3 aren't stable yet and therefore return an "untyped" ReplyUnion. Sentinel TypeMapping Correctly types Multi commands Note: some API changes to be further documented in v4-to-v5.md
This commit is contained in:
@@ -1,37 +1,87 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './GEOSEARCH';
|
||||
import GEOSEARCH from './GEOSEARCH';
|
||||
|
||||
describe('GEOSEARCH', () => {
|
||||
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'member', {
|
||||
radius: 1,
|
||||
unit: 'm'
|
||||
}),
|
||||
['GEOSEARCH', 'key', 'FROMMEMBER', 'member', 'BYRADIUS', '1', 'm']
|
||||
);
|
||||
describe('transformArguments', () => {
|
||||
it('FROMMEMBER, BYRADIUS, without options', () => {
|
||||
assert.deepEqual(
|
||||
GEOSEARCH.transformArguments('key', 'member', {
|
||||
radius: 1,
|
||||
unit: 'm'
|
||||
}),
|
||||
['GEOSEARCH', 'key', 'FROMMEMBER', 'member', 'BYRADIUS', '1', 'm']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.geoSearch', async client => {
|
||||
assert.deepEqual(
|
||||
await client.geoSearch('key', 'member', {
|
||||
radius: 1,
|
||||
unit: 'm'
|
||||
}),
|
||||
[]
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
it('FROMLONLAT, BYBOX, without options', () => {
|
||||
assert.deepEqual(
|
||||
GEOSEARCH.transformArguments('key', {
|
||||
longitude: 1,
|
||||
latitude: 2
|
||||
}, {
|
||||
width: 1,
|
||||
height: 2,
|
||||
unit: 'm'
|
||||
}),
|
||||
['GEOSEARCH', 'key', 'FROMLONLAT', '1', '2', 'BYBOX', '1', '2', 'm']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithCluster('cluster.geoSearch', async cluster => {
|
||||
it('with SORT', () => {
|
||||
assert.deepEqual(
|
||||
GEOSEARCH.transformArguments('key', 'member', {
|
||||
radius: 1,
|
||||
unit: 'm'
|
||||
}, {
|
||||
SORT: 'ASC'
|
||||
}),
|
||||
['GEOSEARCH', 'key', 'FROMMEMBER', 'member', 'BYRADIUS', '1', 'm', 'ASC']
|
||||
);
|
||||
});
|
||||
|
||||
describe('with COUNT', () => {
|
||||
it('number', () => {
|
||||
assert.deepEqual(
|
||||
await cluster.geoSearch('key', 'member', {
|
||||
radius: 1,
|
||||
unit: 'm'
|
||||
}),
|
||||
[]
|
||||
GEOSEARCH.transformArguments('key', 'member', {
|
||||
radius: 1,
|
||||
unit: 'm'
|
||||
}, {
|
||||
COUNT: 1
|
||||
}),
|
||||
['GEOSEARCH', 'key', 'FROMMEMBER', 'member', 'BYRADIUS', '1', 'm', 'COUNT', '1']
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
});
|
||||
|
||||
it('with ANY', () => {
|
||||
assert.deepEqual(
|
||||
GEOSEARCH.transformArguments('key', 'member', {
|
||||
radius: 1,
|
||||
unit: 'm'
|
||||
}, {
|
||||
COUNT: {
|
||||
value: 1,
|
||||
ANY: true
|
||||
}
|
||||
}),
|
||||
['GEOSEARCH', 'key', 'FROMMEMBER', 'member', 'BYRADIUS', '1', 'm', 'COUNT', '1', 'ANY']
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testAll('geoSearch', async client => {
|
||||
assert.deepEqual(
|
||||
await client.geoSearch('key', 'member', {
|
||||
radius: 1,
|
||||
unit: 'm'
|
||||
}),
|
||||
[]
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user