-
Notifications
You must be signed in to change notification settings - Fork 208
/
Copy pathadd-test.ts
102 lines (93 loc) · 2.34 KB
/
add-test.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import * as figc from 'figc';
import { createClient } from '../lib/solr';
import { dataOk, ok } from './utils/sassert';
const config = figc(__dirname + '/config.json');
const client = createClient(config.client);
const basePath = [config.client.path, config.client.core]
.join('/')
.replace(/\/$/, '');
describe('Client', function () {
describe('#add({ id : 1, title_t : "title"},callback)', function () {
it('should add one document', async function () {
const doc = {
id: 1,
title_t: 'title1',
};
const data = await client.add(doc);
dataOk(data);
});
});
describe('#add([{},{},...],callback)', function () {
it('should add all documents in the array', async function () {
const docs = [
{
id: 2,
title_t: 'title2',
},
{
id: 3,
title_t: 'title3',
},
];
const data = await client.add(docs);
dataOk(data);
});
});
describe('#add(docs,{ softCommit : true},callback)', function () {
it('should add all documents with the softCommit option enabled', async function () {
const docs = [
{
id: 4,
title_t: 'title4',
},
{
id: 5,
title_t: 'title5',
},
];
const options = {
softCommit: true,
};
const data = await client.add(docs, options);
dataOk(data);
});
});
describe('#add(docs,{ commit : true},callback)', function () {
it('should add all documents with the commit option enabled', async function () {
const docs = [
{
id: 6,
title_t: 'title6',
},
{
id: 7,
title_t: 'title7',
},
];
const options = {
commit: true,
};
const data = await client.add(docs, options);
dataOk(data);
});
});
describe('#add(docs,{ commitWithin : 10000},callback)', function () {
it('should add all documents with the commitWithin option set to 10s', async function () {
const docs = [
{
id: 8,
title_t: 'title8',
},
{
id: 9,
title_t: 'title9',
},
];
const options = {
commitWithin: 10000,
};
const data = await client.add(docs, options);
dataOk(data);
});
});
});