Skip to content

Commit 068f7f4

Browse files
committed
fix EVAL & EVALSHA, add some tests, npm update
1 parent c19d200 commit 068f7f4

6 files changed

+25
-19
lines changed

lib/commands/EVAL.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,3 @@ import { EvalOptions, pushEvalArguments } from './generic-transformers';
33
export function transformArguments(script: string, options?: EvalOptions): Array<string> {
44
return pushEvalArguments(['EVAL', script], options);
55
}
6-
7-
export function transformReply(reply: unknown): unknown {
8-
return reply;
9-
}

lib/commands/EVALSHA.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,3 @@ import { EvalOptions, pushEvalArguments } from './generic-transformers';
33
export function transformArguments(sha1: string, options?: EvalOptions): Array<string> {
44
return pushEvalArguments(['EVALSHA', sha1], options);
55
}
6-
7-
export function transformReply(reply: unknown): unknown {
8-
return reply;
9-
}

lib/commands/ZRANGESTORE.spec.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { strict as assert } from 'assert';
22
import { TestRedisServers, itWithClient, describeHandleMinimumRedisVersion } from '../test-utils';
3-
import { transformArguments } from './ZRANGESTORE';
3+
import { transformArguments, transformReply } from './ZRANGESTORE';
44

55
describe('ZRANGESTORE', () => {
66
describeHandleMinimumRedisVersion([6, 2]);
@@ -68,6 +68,15 @@ describe('ZRANGESTORE', () => {
6868
});
6969
});
7070

71+
describe('transformReply', () => {
72+
it('should throw TypeError when reply is not a number', () => {
73+
assert.throws(
74+
() => (transformReply as any)([]),
75+
TypeError
76+
);
77+
});
78+
});
79+
7180
itWithClient(TestRedisServers.OPEN, 'client.zRangeStore', async client => {
7281
await client.zAdd('src', {
7382
score: 0.5,

lib/commands/generic-transformers.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,13 @@ describe('Generic Transformers', () => {
300300
);
301301
});
302302

303+
it('with COUNT', () => {
304+
assert.deepEqual(
305+
pushGeoCountArgument([], 1),
306+
['COUNT', '1']
307+
);
308+
});
309+
303310
it('with ANY', () => {
304311
assert.deepEqual(
305312
pushGeoCountArgument([], {

lib/commands/generic-transformers.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,10 @@ export function pushGeoSearchArguments(
204204
args.push('BYBOX', by.width.toString(), by.height.toString());
205205
}
206206

207-
if (by.unit) {
208-
args.push(by.unit);
209-
}
207+
args.push(by.unit);
210208

211209
if (options?.SORT) {
212-
args.push(options?.SORT);
210+
args.push(options.SORT);
213211
}
214212

215213
pushGeoCountArgument(args, options?.COUNT);

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)