forked from redis/node-redis
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.spec.ts
62 lines (56 loc) · 1.56 KB
/
index.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { strict as assert } from 'assert';
import { pushQueryArguments } from '.';
describe('pushQueryArguments', () => {
it('simple', () => {
assert.deepEqual(
pushQueryArguments(['GRAPH.QUERY'], 'graph', 'query'),
['GRAPH.QUERY', 'graph', 'query']
);
});
describe('params', () => {
it('all types', () => {
assert.deepEqual(
pushQueryArguments(['GRAPH.QUERY'], 'graph', 'query', {
params: {
null: null,
string: '"\\',
number: 0,
boolean: false,
array: [0],
object: {a: 0}
}
}),
['GRAPH.QUERY', 'graph', 'CYPHER null=null string="\\"\\\\" number=0 boolean=false array=[0] object={a:0} query']
);
});
it('TypeError', () => {
assert.throws(() => {
pushQueryArguments(['GRAPH.QUERY'], 'graph', 'query', {
params: {
a: undefined as any
}
})
}, TypeError);
});
});
it('TIMEOUT backward compatible', () => {
assert.deepEqual(
pushQueryArguments(['GRAPH.QUERY'], 'graph', 'query', 1),
['GRAPH.QUERY', 'graph', 'query', 'TIMEOUT', '1']
);
});
it('TIMEOUT', () => {
assert.deepEqual(
pushQueryArguments(['GRAPH.QUERY'], 'graph', 'query', {
TIMEOUT: 1
}),
['GRAPH.QUERY', 'graph', 'query', 'TIMEOUT', '1']
);
});
it('compact', () => {
assert.deepEqual(
pushQueryArguments(['GRAPH.QUERY'], 'graph', 'query', undefined, true),
['GRAPH.QUERY', 'graph', 'query', '--compact']
);
});
});