You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-17 19:41:06 +03:00
fix EVAL & EVALSHA, add some tests, npm update
This commit is contained in:
@@ -3,7 +3,3 @@ import { EvalOptions, pushEvalArguments } from './generic-transformers';
|
||||
export function transformArguments(script: string, options?: EvalOptions): Array<string> {
|
||||
return pushEvalArguments(['EVAL', script], options);
|
||||
}
|
||||
|
||||
export function transformReply(reply: unknown): unknown {
|
||||
return reply;
|
||||
}
|
||||
|
@@ -3,7 +3,3 @@ import { EvalOptions, pushEvalArguments } from './generic-transformers';
|
||||
export function transformArguments(sha1: string, options?: EvalOptions): Array<string> {
|
||||
return pushEvalArguments(['EVALSHA', sha1], options);
|
||||
}
|
||||
|
||||
export function transformReply(reply: unknown): unknown {
|
||||
return reply;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, describeHandleMinimumRedisVersion } from '../test-utils';
|
||||
import { transformArguments } from './ZRANGESTORE';
|
||||
import { transformArguments, transformReply } from './ZRANGESTORE';
|
||||
|
||||
describe('ZRANGESTORE', () => {
|
||||
describeHandleMinimumRedisVersion([6, 2]);
|
||||
@@ -68,6 +68,15 @@ describe('ZRANGESTORE', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('transformReply', () => {
|
||||
it('should throw TypeError when reply is not a number', () => {
|
||||
assert.throws(
|
||||
() => (transformReply as any)([]),
|
||||
TypeError
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
itWithClient(TestRedisServers.OPEN, 'client.zRangeStore', async client => {
|
||||
await client.zAdd('src', {
|
||||
score: 0.5,
|
||||
|
@@ -300,6 +300,13 @@ describe('Generic Transformers', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('with COUNT', () => {
|
||||
assert.deepEqual(
|
||||
pushGeoCountArgument([], 1),
|
||||
['COUNT', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('with ANY', () => {
|
||||
assert.deepEqual(
|
||||
pushGeoCountArgument([], {
|
||||
|
@@ -204,12 +204,10 @@ export function pushGeoSearchArguments(
|
||||
args.push('BYBOX', by.width.toString(), by.height.toString());
|
||||
}
|
||||
|
||||
if (by.unit) {
|
||||
args.push(by.unit);
|
||||
}
|
||||
args.push(by.unit);
|
||||
|
||||
if (options?.SORT) {
|
||||
args.push(options?.SORT);
|
||||
args.push(options.SORT);
|
||||
}
|
||||
|
||||
pushGeoCountArgument(args, options?.COUNT);
|
||||
|
Reference in New Issue
Block a user