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

fix DECRBY

This commit is contained in:
dovi
2023-05-03 14:50:33 -04:00
parent e4b8370c03
commit 642c823d1b
2 changed files with 17 additions and 14 deletions

View File

@@ -1,19 +1,22 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './DECRBY';
import DECRBY from './DECRBY';
describe('DECRBY', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 2),
['DECRBY', 'key', '2']
);
});
it('transformArguments', () => {
assert.deepEqual(
DECRBY.transformArguments('key', 2),
['DECRBY', 'key', '2']
);
});
testUtils.testWithClient('client.decrBy', async client => {
assert.equal(
await client.decrBy('key', 2),
-2
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testAll('decrBy', async client => {
assert.equal(
await client.decrBy('key', 2),
-2
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -3,7 +3,7 @@ import { RedisArgument, NumberReply, Command } from '../RESP/types';
export default {
FIRST_KEY_INDEX: 1,
transformArguments(key: RedisArgument, decrement: number) {
return ['DECR', key, decrement.toString()];
return ['DECRBY', key, decrement.toString()];
},
transformReply: undefined as unknown as () => NumberReply
} as const satisfies Command;