Skip to content

Commit d6c7860

Browse files
committed
use the new parseCommand api
1 parent 5d31674 commit d6c7860

14 files changed

+113
-67
lines changed

packages/client/lib/commands/VADD.spec.ts

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,63 @@
11
import { strict as assert } from 'node:assert';
22
import testUtils, { GLOBAL } from '../test-utils';
33
import VADD from './VADD';
4-
import { parseArgs } from './generic-transformers';
4+
import { BasicCommandParser } from '../client/parser';
55

66
describe('VADD', () => {
7-
describe('transformArguments', () => {
7+
describe('parseCommand', () => {
88
it('basic usage', () => {
9+
const parser = new BasicCommandParser();
10+
VADD.parseCommand(parser, 'key', [1.0, 2.0, 3.0], 'element');
911
assert.deepEqual(
10-
parseArgs(VADD, 'key', [1.0, 2.0, 3.0], 'element'),
12+
parser.redisArgs,
1113
['VADD', 'key', 'VALUES', '3', '1', '2', '3', 'element']
1214
);
1315
});
1416

1517
it('with REDUCE option', () => {
18+
const parser = new BasicCommandParser();
19+
VADD.parseCommand(parser, 'key', [1.0, 2], 'element', { REDUCE: 50 });
1620
assert.deepEqual(
17-
parseArgs(VADD, 'key', [1.0, 2], 'element', { REDUCE: 50 }),
21+
parser.redisArgs,
1822
['VADD', 'key', 'REDUCE', '50', 'VALUES', '2', '1', '2', 'element']
1923
);
2024
});
2125

2226
it('with quantization options', () => {
27+
let parser = new BasicCommandParser();
28+
VADD.parseCommand(parser, 'key', [1.0, 2.0], 'element', { QUANT: 'Q8' });
2329
assert.deepEqual(
24-
parseArgs(VADD, 'key', [1.0, 2.0], 'element', { QUANT: 'Q8' }),
30+
parser.redisArgs,
2531
['VADD', 'key', 'VALUES', '2', '1', '2', 'element', 'Q8']
2632
);
2733

34+
parser = new BasicCommandParser();
35+
VADD.parseCommand(parser, 'key', [1.0, 2.0], 'element', { QUANT: 'BIN' });
2836
assert.deepEqual(
29-
parseArgs(VADD, 'key', [1.0, 2.0], 'element', { QUANT: 'BIN' }),
37+
parser.redisArgs,
3038
['VADD', 'key', 'VALUES', '2', '1', '2', 'element', 'BIN']
3139
);
3240

41+
parser = new BasicCommandParser();
42+
VADD.parseCommand(parser, 'key', [1.0, 2.0], 'element', { QUANT: 'NOQUANT' });
3343
assert.deepEqual(
34-
parseArgs(VADD, 'key', [1.0, 2.0], 'element', { QUANT: 'NOQUANT' }),
44+
parser.redisArgs,
3545
['VADD', 'key', 'VALUES', '2', '1', '2', 'element', 'NOQUANT']
3646
);
3747
});
3848

3949
it('with all options', () => {
50+
const parser = new BasicCommandParser();
51+
VADD.parseCommand(parser, 'key', [1.0, 2.0], 'element', {
52+
REDUCE: 50,
53+
CAS: true,
54+
QUANT: 'Q8',
55+
EF: 200,
56+
SETATTR: { name: 'test', value: 42 },
57+
M: 16
58+
});
4059
assert.deepEqual(
41-
parseArgs(VADD, 'key', [1.0, 2.0], 'element', {
42-
REDUCE: 50,
43-
CAS: true,
44-
QUANT: 'Q8',
45-
EF: 200,
46-
SETATTR: { name: 'test', value: 42 },
47-
M: 16
48-
}),
60+
parser.redisArgs,
4961
[
5062
'VADD', 'key', 'REDUCE', '50', 'VALUES', '2', '1', '2', 'element',
5163
'CAS', 'Q8', 'EF', '200', 'SETATTR', '{"name":"test","value":42}', 'M', '16'

packages/client/lib/commands/VCARD.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { strict as assert } from 'node:assert';
22
import testUtils, { GLOBAL } from '../test-utils';
33
import VCARD from './VCARD';
4-
import { parseArgs } from './generic-transformers';
4+
import { BasicCommandParser } from '../client/parser';
55

66
describe('VCARD', () => {
7-
it('transformArguments', () => {
7+
it('parseCommand', () => {
8+
const parser = new BasicCommandParser();
9+
VCARD.parseCommand(parser, 'key')
810
assert.deepEqual(
9-
parseArgs(VCARD, 'key'),
11+
parser.redisArgs,
1012
['VCARD', 'key']
1113
);
1214
});

packages/client/lib/commands/VDIM.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { strict as assert } from 'node:assert';
22
import testUtils, { GLOBAL } from '../test-utils';
33
import VDIM from './VDIM';
4-
import { parseArgs } from './generic-transformers';
4+
import { BasicCommandParser } from '../client/parser';
55

66
describe('VDIM', () => {
7-
it('transformArguments', () => {
7+
it('parseCommand', () => {
8+
const parser = new BasicCommandParser();
9+
VDIM.parseCommand(parser, 'key');
810
assert.deepEqual(
9-
parseArgs(VDIM, 'key'),
11+
parser.redisArgs,
1012
['VDIM', 'key']
1113
);
1214
});

packages/client/lib/commands/VEMB.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { strict as assert } from 'node:assert';
22
import testUtils, { GLOBAL } from '../test-utils';
33
import VEMB from './VEMB';
4-
import { parseArgs } from './generic-transformers';
4+
import { BasicCommandParser } from '../client/parser';
55

66
describe('VEMB', () => {
7-
it('transformArguments', () => {
7+
it('parseCommand', () => {
8+
const parser = new BasicCommandParser();
9+
VEMB.parseCommand(parser, 'key', 'element');
810
assert.deepEqual(
9-
parseArgs(VEMB, 'key', 'element'),
11+
parser.redisArgs,
1012
['VEMB', 'key', 'element']
1113
);
1214
});

packages/client/lib/commands/VEMB_RAW.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { strict as assert } from 'node:assert';
22
import testUtils, { GLOBAL } from '../test-utils';
33
import VEMB_RAW from './VEMB_RAW';
4-
import { parseArgs } from './generic-transformers';
4+
import { BasicCommandParser } from '../client/parser';
55

66
describe('VEMB_RAW', () => {
7-
it('transformArguments', () => {
7+
it('parseCommand', () => {
8+
const parser = new BasicCommandParser();
9+
VEMB_RAW.parseCommand(parser, 'key', 'element');
810
assert.deepEqual(
9-
parseArgs(VEMB_RAW, 'key', 'element'),
11+
parser.redisArgs,
1012
['VEMB', 'key', 'element', 'RAW']
1113
);
1214
});

packages/client/lib/commands/VGETATTR.spec.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { strict as assert } from 'node:assert';
22
import testUtils, { GLOBAL } from '../test-utils';
33
import VGETATTR from './VGETATTR';
4-
import { parseArgs } from './generic-transformers';
4+
import { BasicCommandParser } from '../client/parser';
55

66
describe('VGETATTR', () => {
7-
it('transformArguments', () => {
7+
it('parseCommand', () => {
8+
const parser = new BasicCommandParser();
9+
VGETATTR.parseCommand(parser, 'key', 'element');
810
assert.deepEqual(
9-
parseArgs(VGETATTR, 'key', 'element'),
11+
parser.redisArgs,
1012
['VGETATTR', 'key', 'element']
1113
);
1214
});
@@ -23,7 +25,7 @@ describe('VGETATTR', () => {
2325

2426
assert.ok(result !== null);
2527
assert.equal(typeof result, 'object')
26-
28+
2729
assert.deepEqual(result, {
2830
name: 'test'
2931
})
@@ -56,7 +58,7 @@ describe('VGETATTR', () => {
5658

5759
assert.ok(result !== null);
5860
assert.equal(typeof result, 'object')
59-
61+
6062
assert.deepEqual(result, {
6163
name: 'test-item',
6264
category: 'electronics',

packages/client/lib/commands/VINFO.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { strict as assert } from 'node:assert';
22
import testUtils, { GLOBAL } from '../test-utils';
33
import VINFO from './VINFO';
4-
import { parseArgs } from './generic-transformers';
4+
import { BasicCommandParser } from '../client/parser';
55

66
describe('VINFO', () => {
7-
it('transformArguments', () => {
7+
it('parseCommand', () => {
8+
const parser = new BasicCommandParser();
9+
VINFO.parseCommand(parser, 'key');
810
assert.deepEqual(
9-
parseArgs(VINFO, 'key'),
11+
parser.redisArgs,
1012
['VINFO', 'key']
1113
);
1214
});

packages/client/lib/commands/VLINKS.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { strict as assert } from 'node:assert';
22
import testUtils, { GLOBAL } from '../test-utils';
33
import VLINKS from './VLINKS';
4-
import { parseArgs } from './generic-transformers';
4+
import { BasicCommandParser } from '../client/parser';
55

66
describe('VLINKS', () => {
7-
it('transformArguments', () => {
7+
it('parseCommand', () => {
8+
const parser = new BasicCommandParser();
9+
VLINKS.parseCommand(parser, 'key', 'element');
810
assert.deepEqual(
9-
parseArgs(VLINKS, 'key', 'element'),
11+
parser.redisArgs,
1012
['VLINKS', 'key', 'element']
1113
);
1214
});

packages/client/lib/commands/VLINKS_WITHSCORES.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { strict as assert } from 'node:assert';
22
import testUtils, { GLOBAL } from '../test-utils';
3-
import { parseArgs } from './generic-transformers';
43
import VLINKS_WITHSCORES from './VLINKS_WITHSCORES';
4+
import { BasicCommandParser } from '../client/parser';
55

66
describe('VLINKS WITHSCORES', () => {
7-
it('transformArguments', () => {
8-
assert.deepEqual(parseArgs(VLINKS_WITHSCORES, 'key', 'element'), [
7+
it('parseCommand', () => {
8+
const parser = new BasicCommandParser();
9+
VLINKS_WITHSCORES.parseCommand(parser, 'key', 'element');
10+
assert.deepEqual(parser.redisArgs, [
911
'VLINKS',
1012
'key',
1113
'element',

packages/client/lib/commands/VRANDMEMBER.spec.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
import { strict as assert } from 'node:assert';
22
import testUtils, { GLOBAL } from '../test-utils';
33
import VRANDMEMBER from './VRANDMEMBER';
4-
import { parseArgs } from './generic-transformers';
4+
import { BasicCommandParser } from '../client/parser';
55

66
describe('VRANDMEMBER', () => {
7-
describe('transformArguments', () => {
7+
describe('parseCommand', () => {
88
it('without count', () => {
9+
const parser = new BasicCommandParser();
10+
VRANDMEMBER.parseCommand(parser, 'key');
911
assert.deepEqual(
10-
parseArgs(VRANDMEMBER, 'key'),
12+
parser.redisArgs,
1113
['VRANDMEMBER', 'key']
1214
);
1315
});
1416

1517
it('with count', () => {
18+
const parser = new BasicCommandParser();
19+
VRANDMEMBER.parseCommand(parser, 'key', 2);
1620
assert.deepEqual(
17-
parseArgs(VRANDMEMBER, 'key', 2),
21+
parser.redisArgs,
1822
['VRANDMEMBER', 'key', '2']
1923
);
2024
});

0 commit comments

Comments
 (0)