1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-10 11:43:01 +03:00
Files
node-redis/lib/commands/ZRANGE.spec.ts
2021-06-18 16:51:30 -04:00

66 lines
1.8 KiB
TypeScript

import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import { transformArguments } from './ZRANGE';
describe('ZRANGE', () => {
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments('src', 0, 1),
['ZRANGE', 'src', '0', '1']
);
});
it('with BY', () => {
assert.deepEqual(
transformArguments('src', 0, 1, {
BY: 'SCORE'
}),
['ZRANGE', 'src', '0', '1', 'BYSCORE']
);
});
it('with REV', () => {
assert.deepEqual(
transformArguments('src', 0, 1, {
REV: true
}),
['ZRANGE', 'src', '0', '1', 'REV']
);
});
it('with LIMIT', () => {
assert.deepEqual(
transformArguments('src', 0, 1, {
LIMIT: {
offset: 0,
count: 1
}
}),
['ZRANGE', 'src', '0', '1', 'LIMIT', '0', '1']
);
});
it('with BY & REV & LIMIT', () => {
assert.deepEqual(
transformArguments('src', 0, 1, {
BY: 'SCORE',
REV: true,
LIMIT: {
offset: 0,
count: 1
}
}),
['ZRANGE', 'src', '0', '1', 'BYSCORE', 'REV', 'LIMIT', '0', '1']
);
});
});
itWithClient(TestRedisServers.OPEN, 'client.zRange', async client => {
assert.deepEqual(
await client.zRange('src', 0, 1),
[]
);
});
});