You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
82 lines
2.2 KiB
TypeScript
82 lines
2.2 KiB
TypeScript
import { strict as assert } from 'node:assert';
|
|
import testUtils, { GLOBAL } from '../test-utils';
|
|
import ZRANGESTORE from './ZRANGESTORE';
|
|
|
|
describe('ZRANGESTORE', () => {
|
|
testUtils.isVersionGreaterThanHook([6, 2]);
|
|
|
|
describe('transformArguments', () => {
|
|
it('simple', () => {
|
|
assert.deepEqual(
|
|
ZRANGESTORE.transformArguments('destination', 'source', 0, 1),
|
|
['ZRANGESTORE', 'destination', 'source', '0', '1']
|
|
);
|
|
});
|
|
|
|
it('with BYSCORE', () => {
|
|
assert.deepEqual(
|
|
ZRANGESTORE.transformArguments('destination', 'source', 0, 1, {
|
|
BY: 'SCORE'
|
|
}),
|
|
['ZRANGESTORE', 'destination', 'source', '0', '1', 'BYSCORE']
|
|
);
|
|
});
|
|
|
|
it('with BYLEX', () => {
|
|
assert.deepEqual(
|
|
ZRANGESTORE.transformArguments('destination', 'source', 0, 1, {
|
|
BY: 'LEX'
|
|
}),
|
|
['ZRANGESTORE', 'destination', 'source', '0', '1', 'BYLEX']
|
|
);
|
|
});
|
|
|
|
it('with REV', () => {
|
|
assert.deepEqual(
|
|
ZRANGESTORE.transformArguments('destination', 'source', 0, 1, {
|
|
REV: true
|
|
}),
|
|
['ZRANGESTORE', 'destination', 'source', '0', '1', 'REV']
|
|
);
|
|
});
|
|
|
|
it('with LIMIT', () => {
|
|
assert.deepEqual(
|
|
ZRANGESTORE.transformArguments('destination', 'source', 0, 1, {
|
|
LIMIT: {
|
|
offset: 0,
|
|
count: 1
|
|
}
|
|
}),
|
|
['ZRANGESTORE', 'destination', 'source', '0', '1', 'LIMIT', '0', '1']
|
|
);
|
|
});
|
|
|
|
it('with BY & REV & LIMIT', () => {
|
|
assert.deepEqual(
|
|
ZRANGESTORE.transformArguments('destination', 'source', 0, 1, {
|
|
BY: 'SCORE',
|
|
REV: true,
|
|
LIMIT: {
|
|
offset: 0,
|
|
count: 1
|
|
}
|
|
}),
|
|
['ZRANGESTORE', 'destination', 'source', '0', '1', 'BYSCORE', 'REV', 'LIMIT', '0', '1']
|
|
);
|
|
});
|
|
});
|
|
|
|
testUtils.testWithClient('client.zRangeStore', async client => {
|
|
const [, reply] = await Promise.all([
|
|
client.zAdd('{tag}source', {
|
|
score: 1,
|
|
value: '1'
|
|
}),
|
|
client.zRangeStore('{tag}destination', '{tag}source', 0, 1)
|
|
]);
|
|
|
|
assert.equal(reply, 1);
|
|
}, GLOBAL.SERVERS.OPEN);
|
|
});
|