@mongosh/autocomplete 1.10.1 → 1.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.depcheckrc +11 -0
- package/.eslintrc.js +10 -1
- package/.prettierignore +6 -0
- package/.prettierrc.json +1 -0
- package/README.md +7 -5
- package/lib/index.d.ts +1 -1
- package/lib/index.js +51 -38
- package/lib/index.js.map +1 -1
- package/package.json +19 -9
- package/src/index.spec.ts +393 -290
- package/src/index.ts +146 -73
- package/tsconfig-lint.json +5 -0
- package/tsconfig.json +3 -7
- package/tsconfig.lint.json +0 -8
package/src/index.spec.ts
CHANGED
|
@@ -11,10 +11,10 @@ const standalone600 = {
|
|
|
11
11
|
connectionInfo: () => ({
|
|
12
12
|
is_atlas: false,
|
|
13
13
|
is_data_federation: false,
|
|
14
|
-
server_version: '6.0.0'
|
|
14
|
+
server_version: '6.0.0',
|
|
15
15
|
}),
|
|
16
16
|
getCollectionCompletionsForCurrentDb: () => collections,
|
|
17
|
-
getDatabaseCompletions: () => databases
|
|
17
|
+
getDatabaseCompletions: () => databases,
|
|
18
18
|
};
|
|
19
19
|
const standalone440 = {
|
|
20
20
|
topology: () => Topologies.Standalone,
|
|
@@ -22,17 +22,21 @@ const standalone440 = {
|
|
|
22
22
|
connectionInfo: () => ({
|
|
23
23
|
is_atlas: false,
|
|
24
24
|
is_data_federation: false,
|
|
25
|
-
server_version: '4.4.0'
|
|
25
|
+
server_version: '4.4.0',
|
|
26
26
|
}),
|
|
27
27
|
getCollectionCompletionsForCurrentDb: () => collections,
|
|
28
|
-
getDatabaseCompletions: () => databases
|
|
28
|
+
getDatabaseCompletions: () => databases,
|
|
29
29
|
};
|
|
30
30
|
const apiStrictParams = {
|
|
31
31
|
topology: () => Topologies.Standalone,
|
|
32
|
-
apiVersionInfo: () => ({
|
|
32
|
+
apiVersionInfo: () => ({
|
|
33
|
+
version: '1',
|
|
34
|
+
strict: true,
|
|
35
|
+
deprecationErrors: false,
|
|
36
|
+
}),
|
|
33
37
|
connectionInfo: () => undefined,
|
|
34
38
|
getCollectionCompletionsForCurrentDb: () => collections,
|
|
35
|
-
getDatabaseCompletions: () => databases
|
|
39
|
+
getDatabaseCompletions: () => databases,
|
|
36
40
|
};
|
|
37
41
|
const sharded440 = {
|
|
38
42
|
topology: () => Topologies.Sharded,
|
|
@@ -40,10 +44,10 @@ const sharded440 = {
|
|
|
40
44
|
connectionInfo: () => ({
|
|
41
45
|
is_atlas: false,
|
|
42
46
|
is_data_federation: false,
|
|
43
|
-
server_version: '4.4.0'
|
|
47
|
+
server_version: '4.4.0',
|
|
44
48
|
}),
|
|
45
49
|
getCollectionCompletionsForCurrentDb: () => collections,
|
|
46
|
-
getDatabaseCompletions: () => databases
|
|
50
|
+
getDatabaseCompletions: () => databases,
|
|
47
51
|
};
|
|
48
52
|
|
|
49
53
|
const standalone300 = {
|
|
@@ -52,10 +56,10 @@ const standalone300 = {
|
|
|
52
56
|
connectionInfo: () => ({
|
|
53
57
|
is_atlas: false,
|
|
54
58
|
is_data_federation: false,
|
|
55
|
-
server_version: '3.0.0'
|
|
59
|
+
server_version: '3.0.0',
|
|
56
60
|
}),
|
|
57
61
|
getCollectionCompletionsForCurrentDb: () => collections,
|
|
58
|
-
getDatabaseCompletions: () => databases
|
|
62
|
+
getDatabaseCompletions: () => databases,
|
|
59
63
|
};
|
|
60
64
|
const datalake440 = {
|
|
61
65
|
topology: () => Topologies.Sharded,
|
|
@@ -63,10 +67,10 @@ const datalake440 = {
|
|
|
63
67
|
connectionInfo: () => ({
|
|
64
68
|
is_atlas: true,
|
|
65
69
|
is_data_federation: true,
|
|
66
|
-
server_version: '4.4.0'
|
|
70
|
+
server_version: '4.4.0',
|
|
67
71
|
}),
|
|
68
72
|
getCollectionCompletionsForCurrentDb: () => collections,
|
|
69
|
-
getDatabaseCompletions: () => databases
|
|
73
|
+
getDatabaseCompletions: () => databases,
|
|
70
74
|
};
|
|
71
75
|
|
|
72
76
|
const noParams = {
|
|
@@ -74,7 +78,7 @@ const noParams = {
|
|
|
74
78
|
apiVersionInfo: () => undefined,
|
|
75
79
|
connectionInfo: () => undefined,
|
|
76
80
|
getCollectionCompletionsForCurrentDb: () => collections,
|
|
77
|
-
getDatabaseCompletions: () => databases
|
|
81
|
+
getDatabaseCompletions: () => databases,
|
|
78
82
|
};
|
|
79
83
|
|
|
80
84
|
const emptyConnectionInfoParams = {
|
|
@@ -82,47 +86,51 @@ const emptyConnectionInfoParams = {
|
|
|
82
86
|
apiVersionInfo: () => undefined,
|
|
83
87
|
connectionInfo: () => ({}),
|
|
84
88
|
getCollectionCompletionsForCurrentDb: () => collections,
|
|
85
|
-
getDatabaseCompletions: () => databases
|
|
89
|
+
getDatabaseCompletions: () => databases,
|
|
86
90
|
};
|
|
87
91
|
|
|
88
|
-
describe('completer.completer', ()
|
|
89
|
-
beforeEach(()
|
|
92
|
+
describe('completer.completer', function () {
|
|
93
|
+
beforeEach(function () {
|
|
90
94
|
collections = [];
|
|
91
95
|
});
|
|
92
96
|
|
|
93
|
-
it('returns case-insensitive results', async()
|
|
97
|
+
it('returns case-insensitive results', async function () {
|
|
94
98
|
const input = 'db.getr';
|
|
95
99
|
const [completions] = await completer(noParams as any, input);
|
|
96
100
|
expect(completions).to.deep.eq([
|
|
97
101
|
'db.getRole',
|
|
98
102
|
'db.getRoles',
|
|
99
|
-
'db.getReplicationInfo'
|
|
103
|
+
'db.getReplicationInfo',
|
|
100
104
|
]);
|
|
101
105
|
});
|
|
102
106
|
|
|
103
|
-
context('when context is top level shell api', ()
|
|
104
|
-
it('matches shell completions', async()
|
|
107
|
+
context('when context is top level shell api', function () {
|
|
108
|
+
it('matches shell completions', async function () {
|
|
105
109
|
const i = 'u';
|
|
106
110
|
expect(await completer(standalone440, i)).to.deep.equal([['use'], i]);
|
|
107
111
|
});
|
|
108
112
|
|
|
109
|
-
it('does not have a match', async()
|
|
113
|
+
it('does not have a match', async function () {
|
|
110
114
|
const i = 'ad';
|
|
111
115
|
expect(await completer(standalone440, i)).to.deep.equal([[], i]);
|
|
112
116
|
});
|
|
113
117
|
|
|
114
|
-
it('is an exact match to one of shell completions', async()
|
|
118
|
+
it('is an exact match to one of shell completions', async function () {
|
|
115
119
|
const i = 'use';
|
|
116
|
-
expect(await completer(standalone440, i)).to.deep.equal([
|
|
120
|
+
expect(await completer(standalone440, i)).to.deep.equal([
|
|
121
|
+
[],
|
|
122
|
+
i,
|
|
123
|
+
'exclusive',
|
|
124
|
+
]);
|
|
117
125
|
});
|
|
118
126
|
});
|
|
119
127
|
|
|
120
128
|
[
|
|
121
129
|
{ params: noParams, label: 'no version' },
|
|
122
|
-
{ params: emptyConnectionInfoParams, label: 'empty connection info' }
|
|
130
|
+
{ params: emptyConnectionInfoParams, label: 'empty connection info' },
|
|
123
131
|
].forEach(({ params, label }) => {
|
|
124
|
-
context(`when ${label} is passed to completer`, ()
|
|
125
|
-
it('matches all db completions', async()
|
|
132
|
+
context(`when ${label} is passed to completer`, function () {
|
|
133
|
+
it('matches all db completions', async function () {
|
|
126
134
|
const i = 'db.';
|
|
127
135
|
const c = await completer(params as any, i);
|
|
128
136
|
expect(c.length).to.equal(2);
|
|
@@ -160,29 +168,35 @@ describe('completer.completer', () => {
|
|
|
160
168
|
'db.grantPrivilegesToRole',
|
|
161
169
|
'db.revokePrivilegesFromRole',
|
|
162
170
|
'db.getRole',
|
|
163
|
-
'db.getRoles'
|
|
171
|
+
'db.getRoles',
|
|
164
172
|
]);
|
|
165
173
|
});
|
|
166
174
|
|
|
167
|
-
it('does not have a match', async()
|
|
175
|
+
it('does not have a match', async function () {
|
|
168
176
|
const i = 'db.shipwrecks.aggregate([ { $so';
|
|
169
177
|
expect(await completer(noParams, i)).to.deep.equal([
|
|
170
|
-
[
|
|
178
|
+
[
|
|
179
|
+
'db.shipwrecks.aggregate([ { $sortArray',
|
|
171
180
|
'db.shipwrecks.aggregate([ { $sort',
|
|
172
|
-
'db.shipwrecks.aggregate([ { $sortByCount'
|
|
181
|
+
'db.shipwrecks.aggregate([ { $sortByCount',
|
|
182
|
+
],
|
|
183
|
+
i,
|
|
184
|
+
]);
|
|
173
185
|
});
|
|
174
186
|
|
|
175
|
-
it('is an exact match to one of shell completions', async()
|
|
187
|
+
it('is an exact match to one of shell completions', async function () {
|
|
176
188
|
const i = 'db.bios.find({ field: { $exis';
|
|
177
|
-
expect(await completer(noParams, i))
|
|
178
|
-
|
|
189
|
+
expect(await completer(noParams, i)).to.deep.equal([
|
|
190
|
+
['db.bios.find({ field: { $exists'],
|
|
191
|
+
i,
|
|
192
|
+
]);
|
|
179
193
|
});
|
|
180
194
|
});
|
|
181
195
|
});
|
|
182
196
|
|
|
183
|
-
context('datalake features', ()
|
|
197
|
+
context('datalake features', function () {
|
|
184
198
|
let origBaseCompletions: any[];
|
|
185
|
-
beforeEach(()
|
|
199
|
+
beforeEach(function () {
|
|
186
200
|
// Undo https://github.com/mongodb-js/ace-autocompleter/pull/65 for testing
|
|
187
201
|
// because it's the only DataLake-only feature.
|
|
188
202
|
origBaseCompletions = [...BASE_COMPLETIONS];
|
|
@@ -191,166 +205,219 @@ describe('completer.completer', () => {
|
|
|
191
205
|
value: '$sql',
|
|
192
206
|
label: '$sql',
|
|
193
207
|
score: 1,
|
|
194
|
-
env: [
|
|
208
|
+
env: ['adl'],
|
|
195
209
|
meta: 'stage',
|
|
196
|
-
version: '4.0.0'
|
|
210
|
+
version: '4.0.0',
|
|
197
211
|
});
|
|
198
212
|
});
|
|
199
|
-
afterEach(()
|
|
200
|
-
BASE_COMPLETIONS.splice(
|
|
213
|
+
afterEach(function () {
|
|
214
|
+
BASE_COMPLETIONS.splice(
|
|
215
|
+
0,
|
|
216
|
+
BASE_COMPLETIONS.length,
|
|
217
|
+
...origBaseCompletions
|
|
218
|
+
);
|
|
201
219
|
});
|
|
202
220
|
|
|
203
|
-
it('includes them when not connected', async()
|
|
221
|
+
it('includes them when not connected', async function () {
|
|
204
222
|
const i = 'db.shipwrecks.aggregate([ { $sq';
|
|
205
223
|
expect(await completer(noParams, i)).to.deep.equal([
|
|
206
|
-
[
|
|
207
|
-
'db.shipwrecks.aggregate([ { $
|
|
224
|
+
[
|
|
225
|
+
'db.shipwrecks.aggregate([ { $sqrt',
|
|
226
|
+
'db.shipwrecks.aggregate([ { $sql',
|
|
227
|
+
],
|
|
228
|
+
i,
|
|
229
|
+
]);
|
|
208
230
|
});
|
|
209
231
|
|
|
210
|
-
it('includes them when connected to DataLake', async()
|
|
232
|
+
it('includes them when connected to DataLake', async function () {
|
|
211
233
|
const i = 'db.shipwrecks.aggregate([ { $sq';
|
|
212
234
|
expect(await completer(datalake440, i)).to.deep.equal([
|
|
213
|
-
[
|
|
214
|
-
'db.shipwrecks.aggregate([ { $
|
|
235
|
+
[
|
|
236
|
+
'db.shipwrecks.aggregate([ { $sqrt',
|
|
237
|
+
'db.shipwrecks.aggregate([ { $sql',
|
|
238
|
+
],
|
|
239
|
+
i,
|
|
240
|
+
]);
|
|
215
241
|
});
|
|
216
242
|
|
|
217
|
-
it('does not include them when connected to a standalone node', async()
|
|
243
|
+
it('does not include them when connected to a standalone node', async function () {
|
|
218
244
|
const i = 'db.shipwrecks.aggregate([ { $sq';
|
|
219
245
|
expect(await completer(standalone440, i)).to.deep.equal([
|
|
220
|
-
['db.shipwrecks.aggregate([ { $sqrt'],
|
|
246
|
+
['db.shipwrecks.aggregate([ { $sqrt'],
|
|
247
|
+
i,
|
|
248
|
+
]);
|
|
221
249
|
});
|
|
222
250
|
});
|
|
223
251
|
|
|
224
|
-
context('when context is top level db', ()
|
|
252
|
+
context('when context is top level db', function () {
|
|
225
253
|
// this should eventually encompass tests for DATABASE commands and
|
|
226
254
|
// COLLECTION names.
|
|
227
255
|
// for now, this will only return the current input.
|
|
228
|
-
it('matches a database command', async()
|
|
256
|
+
it('matches a database command', async function () {
|
|
229
257
|
const i = 'db.agg';
|
|
230
|
-
expect(await completer(standalone440, i)).to.deep.equal([
|
|
258
|
+
expect(await completer(standalone440, i)).to.deep.equal([
|
|
259
|
+
['db.aggregate'],
|
|
260
|
+
i,
|
|
261
|
+
]);
|
|
231
262
|
});
|
|
232
263
|
|
|
233
|
-
it('returns all suggestions', async()
|
|
264
|
+
it('returns all suggestions', async function () {
|
|
234
265
|
const i = 'db.';
|
|
235
266
|
const attr = shellSignatures.Database.attributes as any;
|
|
236
267
|
const dbComplete = Object.keys(attr);
|
|
237
268
|
const adjusted = dbComplete
|
|
238
|
-
.filter(c => !attr[c].deprecated)
|
|
239
|
-
.map(c => `${i}${c}`);
|
|
269
|
+
.filter((c) => !attr[c].deprecated)
|
|
270
|
+
.map((c) => `${i}${c}`);
|
|
240
271
|
expect(await completer(noParams, i)).to.deep.equal([adjusted, i]);
|
|
241
272
|
});
|
|
242
273
|
|
|
243
|
-
it('matches several suggestions', async()
|
|
274
|
+
it('matches several suggestions', async function () {
|
|
244
275
|
const i = 'db.get';
|
|
245
|
-
expect((await completer(standalone440, i))[0]).to.include.members(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
]);
|
|
276
|
+
expect((await completer(standalone440, i))[0]).to.include.members([
|
|
277
|
+
'db.getCollectionNames',
|
|
278
|
+
'db.getCollection',
|
|
279
|
+
'db.getCollectionInfos',
|
|
280
|
+
'db.getSiblingDB',
|
|
281
|
+
]);
|
|
252
282
|
});
|
|
253
283
|
|
|
254
|
-
it('returns current input and no suggestions', async()
|
|
284
|
+
it('returns current input and no suggestions', async function () {
|
|
255
285
|
const i = 'db.shipw';
|
|
256
286
|
expect(await completer(standalone440, i)).to.deep.equal([[], i]);
|
|
257
287
|
});
|
|
258
288
|
|
|
259
|
-
it('includes collection names', async()
|
|
289
|
+
it('includes collection names', async function () {
|
|
260
290
|
collections = ['shipwrecks'];
|
|
261
291
|
const i = 'db.shipw';
|
|
262
|
-
expect(await completer(standalone440, i)).to.deep.equal([
|
|
292
|
+
expect(await completer(standalone440, i)).to.deep.equal([
|
|
293
|
+
['db.shipwrecks'],
|
|
294
|
+
i,
|
|
295
|
+
]);
|
|
263
296
|
});
|
|
264
297
|
});
|
|
265
298
|
|
|
266
|
-
context('when context is collections', ()
|
|
267
|
-
it('matches a collection command', async()
|
|
299
|
+
context('when context is collections', function () {
|
|
300
|
+
it('matches a collection command', async function () {
|
|
268
301
|
const i = 'db.shipwrecks.findOneAndUp';
|
|
269
|
-
expect(await completer(standalone440, i)).to.deep.equal([
|
|
302
|
+
expect(await completer(standalone440, i)).to.deep.equal([
|
|
303
|
+
['db.shipwrecks.findOneAndUpdate'],
|
|
304
|
+
i,
|
|
305
|
+
]);
|
|
270
306
|
});
|
|
271
307
|
|
|
272
|
-
it('matches a collection command if part of an expression', async()
|
|
308
|
+
it('matches a collection command if part of an expression', async function () {
|
|
273
309
|
const i = 'var result = db.shipwrecks.findOneAndUp';
|
|
274
|
-
expect(await completer(standalone440, i)).to.deep.equal([
|
|
310
|
+
expect(await completer(standalone440, i)).to.deep.equal([
|
|
311
|
+
['var result = db.shipwrecks.findOneAndUpdate'],
|
|
312
|
+
i,
|
|
313
|
+
]);
|
|
275
314
|
});
|
|
276
315
|
|
|
277
|
-
it('returns all suggestions', async()
|
|
316
|
+
it('returns all suggestions', async function () {
|
|
278
317
|
const i = 'db.shipwrecks.';
|
|
279
|
-
const collComplete = Object.keys(
|
|
318
|
+
const collComplete = Object.keys(
|
|
319
|
+
shellSignatures.Collection.attributes as any
|
|
320
|
+
);
|
|
280
321
|
const adjusted = collComplete
|
|
281
|
-
.filter(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
322
|
+
.filter(
|
|
323
|
+
(c) =>
|
|
324
|
+
![
|
|
325
|
+
'count',
|
|
326
|
+
'update',
|
|
327
|
+
'remove',
|
|
328
|
+
'insert',
|
|
329
|
+
'save',
|
|
330
|
+
'findAndModify',
|
|
331
|
+
'reIndex',
|
|
332
|
+
'mapReduce',
|
|
333
|
+
// 6.0+
|
|
334
|
+
'getSearchIndexes',
|
|
335
|
+
'createSearchIndex',
|
|
336
|
+
'createSearchIndexes',
|
|
337
|
+
'dropSearchIndex',
|
|
338
|
+
'updateSearchIndex',
|
|
339
|
+
// 7.0+
|
|
340
|
+
'checkMetadataConsistency',
|
|
341
|
+
'analyzeShardKey',
|
|
342
|
+
'configureQueryAnalyzer',
|
|
343
|
+
].includes(c)
|
|
289
344
|
)
|
|
290
|
-
.map(c => `${i}${c}`);
|
|
345
|
+
.map((c) => `${i}${c}`);
|
|
291
346
|
|
|
292
347
|
expect(await completer(sharded440, i)).to.deep.equal([adjusted, i]);
|
|
293
348
|
});
|
|
294
349
|
|
|
295
|
-
it('matches several collection commands', async()
|
|
350
|
+
it('matches several collection commands', async function () {
|
|
296
351
|
const i = 'db.shipwrecks.find';
|
|
297
352
|
expect(await completer(standalone440, i)).to.deep.equal([
|
|
298
353
|
[
|
|
299
354
|
'db.shipwrecks.find',
|
|
300
|
-
'db.shipwrecks.findOne',
|
|
301
|
-
'db.shipwrecks.
|
|
302
|
-
|
|
355
|
+
'db.shipwrecks.findOne',
|
|
356
|
+
'db.shipwrecks.findOneAndDelete',
|
|
357
|
+
'db.shipwrecks.findOneAndReplace',
|
|
358
|
+
'db.shipwrecks.findOneAndUpdate',
|
|
359
|
+
],
|
|
360
|
+
i,
|
|
361
|
+
]);
|
|
303
362
|
});
|
|
304
363
|
|
|
305
|
-
it('does not have a match', async()
|
|
364
|
+
it('does not have a match', async function () {
|
|
306
365
|
const i = 'db.shipwrecks.pr';
|
|
307
366
|
expect(await completer(standalone440, i)).to.deep.equal([[], i]);
|
|
308
367
|
});
|
|
309
368
|
|
|
310
|
-
it('does not provide anything if there is a function call instead of a collection name', async()
|
|
369
|
+
it('does not provide anything if there is a function call instead of a collection name', async function () {
|
|
311
370
|
const i = 'db.getMongo().find';
|
|
312
371
|
expect(await completer(standalone440, i)).to.deep.equal([[], i]);
|
|
313
372
|
});
|
|
314
373
|
|
|
315
|
-
it('provides results if the function call is getCollection', async()
|
|
374
|
+
it('provides results if the function call is getCollection', async function () {
|
|
316
375
|
const i = 'db.getCollection("foo").find';
|
|
317
|
-
expect((await completer(standalone440, i))[0].length).to.be.greaterThan(
|
|
376
|
+
expect((await completer(standalone440, i))[0].length).to.be.greaterThan(
|
|
377
|
+
1
|
|
378
|
+
);
|
|
318
379
|
});
|
|
319
380
|
});
|
|
320
381
|
|
|
321
|
-
context('when context is collections and aggregation cursor', ()
|
|
322
|
-
it('matches an aggregation cursor command', async()
|
|
382
|
+
context('when context is collections and aggregation cursor', function () {
|
|
383
|
+
it('matches an aggregation cursor command', async function () {
|
|
323
384
|
const i = 'db.shipwrecks.aggregate([{$sort: {feature_type: 1}}]).has';
|
|
324
385
|
expect(await completer(standalone440, i)).to.deep.equal([
|
|
325
|
-
['db.shipwrecks.aggregate([{$sort: {feature_type: 1}}]).hasNext'],
|
|
386
|
+
['db.shipwrecks.aggregate([{$sort: {feature_type: 1}}]).hasNext'],
|
|
387
|
+
i,
|
|
388
|
+
]);
|
|
326
389
|
});
|
|
327
390
|
|
|
328
|
-
it('returns all suggestions', async()
|
|
391
|
+
it('returns all suggestions', async function () {
|
|
329
392
|
const i = 'db.shipwrecks.aggregate([{$sort: {feature_type: 1}}]).';
|
|
330
|
-
const aggCursorComplete = Object.keys(
|
|
331
|
-
|
|
393
|
+
const aggCursorComplete = Object.keys(
|
|
394
|
+
shellSignatures.AggregationCursor.attributes as any
|
|
395
|
+
);
|
|
396
|
+
const adjusted = aggCursorComplete.map((c) => `${i}${c}`);
|
|
332
397
|
|
|
333
398
|
expect(await completer(standalone440, i)).to.deep.equal([adjusted, i]);
|
|
334
399
|
});
|
|
335
400
|
|
|
336
|
-
it('does not have a match', async()
|
|
401
|
+
it('does not have a match', async function () {
|
|
337
402
|
const i = 'db.shipwrecks.aggregate([{$sort: {feature_type: 1}}]).w';
|
|
338
403
|
expect(await completer(standalone440, i)).to.deep.equal([[], i]);
|
|
339
404
|
});
|
|
340
405
|
|
|
341
|
-
it('has several matches', async()
|
|
406
|
+
it('has several matches', async function () {
|
|
342
407
|
const i = 'db.shipwrecks.aggregate([{$sort: {feature_type: 1}}]).i';
|
|
343
408
|
expect(await completer(standalone440, i)).to.deep.equal([
|
|
344
409
|
[
|
|
345
410
|
'db.shipwrecks.aggregate([{$sort: {feature_type: 1}}]).isClosed',
|
|
346
411
|
'db.shipwrecks.aggregate([{$sort: {feature_type: 1}}]).isExhausted',
|
|
347
|
-
'db.shipwrecks.aggregate([{$sort: {feature_type: 1}}]).itcount'
|
|
348
|
-
],
|
|
412
|
+
'db.shipwrecks.aggregate([{$sort: {feature_type: 1}}]).itcount',
|
|
413
|
+
],
|
|
414
|
+
i,
|
|
415
|
+
]);
|
|
349
416
|
});
|
|
350
417
|
});
|
|
351
418
|
|
|
352
|
-
context('when context is db aggregation query', ()
|
|
353
|
-
it('has several matches for db level stages', async()
|
|
419
|
+
context('when context is db aggregation query', function () {
|
|
420
|
+
it('has several matches for db level stages', async function () {
|
|
354
421
|
const query = 'db.aggregate([{';
|
|
355
422
|
expect(await completer(standalone440, query)).to.deep.equal([
|
|
356
423
|
[
|
|
@@ -358,7 +425,7 @@ describe('completer.completer', () => {
|
|
|
358
425
|
'db.aggregate([{$currentOp',
|
|
359
426
|
'db.aggregate([{$listLocalSessions',
|
|
360
427
|
],
|
|
361
|
-
query
|
|
428
|
+
query,
|
|
362
429
|
]);
|
|
363
430
|
expect(await completer(standalone600, query)).to.deep.equal([
|
|
364
431
|
[
|
|
@@ -367,113 +434,121 @@ describe('completer.completer', () => {
|
|
|
367
434
|
'db.aggregate([{$currentOp',
|
|
368
435
|
'db.aggregate([{$listLocalSessions',
|
|
369
436
|
],
|
|
370
|
-
query
|
|
437
|
+
query,
|
|
371
438
|
]);
|
|
372
439
|
});
|
|
373
440
|
|
|
374
|
-
it('does not have a match', async()
|
|
441
|
+
it('does not have a match', async function () {
|
|
375
442
|
const query = 'db.aggregate([{$mat';
|
|
376
443
|
expect(await completer(standalone440, query)).to.deep.equal([[], query]);
|
|
377
444
|
});
|
|
378
445
|
|
|
379
|
-
it('matches a db aggregation stage', async()
|
|
446
|
+
it('matches a db aggregation stage', async function () {
|
|
380
447
|
const query = 'db.aggregate([{$lis';
|
|
381
448
|
expect(await completer(standalone440, query)).to.deep.equal([
|
|
382
449
|
['db.aggregate([{$listLocalSessions'],
|
|
383
|
-
query
|
|
450
|
+
query,
|
|
384
451
|
]);
|
|
385
452
|
});
|
|
386
453
|
|
|
387
|
-
it('completes the followup stages', async()
|
|
454
|
+
it('completes the followup stages', async function () {
|
|
388
455
|
const query = 'db.aggregate([{$currentOp: {}}, {$ma';
|
|
389
456
|
expect(await completer(standalone440, query)).to.deep.equal([
|
|
390
457
|
[
|
|
391
458
|
'db.aggregate([{$currentOp: {}}, {$map',
|
|
392
|
-
'db.aggregate([{$currentOp: {}}, {$match'
|
|
459
|
+
'db.aggregate([{$currentOp: {}}, {$match',
|
|
393
460
|
],
|
|
394
|
-
query
|
|
461
|
+
query,
|
|
395
462
|
]);
|
|
396
463
|
});
|
|
397
464
|
});
|
|
398
465
|
|
|
399
|
-
context('when context is aggregation query', ()
|
|
400
|
-
it('has several matches', async()
|
|
466
|
+
context('when context is aggregation query', function () {
|
|
467
|
+
it('has several matches', async function () {
|
|
401
468
|
const i = 'db.shipwrecks.aggregate([ { $so';
|
|
402
469
|
expect(await completer(standalone440, i)).to.deep.equal([
|
|
403
|
-
[
|
|
404
|
-
'db.shipwrecks.aggregate([ { $
|
|
470
|
+
[
|
|
471
|
+
'db.shipwrecks.aggregate([ { $sort',
|
|
472
|
+
'db.shipwrecks.aggregate([ { $sortByCount',
|
|
473
|
+
],
|
|
474
|
+
i,
|
|
475
|
+
]);
|
|
405
476
|
});
|
|
406
477
|
|
|
407
|
-
it('does not have a match', async()
|
|
478
|
+
it('does not have a match', async function () {
|
|
408
479
|
const i = 'db.shipwrecks.aggregate([ { $cat';
|
|
409
480
|
expect(await completer(standalone440, i)).to.deep.equal([[], i]);
|
|
410
481
|
});
|
|
411
482
|
|
|
412
|
-
it('matches an aggregation stage', async()
|
|
483
|
+
it('matches an aggregation stage', async function () {
|
|
413
484
|
const i = 'db.shipwrecks.aggregate([ { $proj';
|
|
414
485
|
expect(await completer(standalone440, i)).to.deep.equal([
|
|
415
|
-
[
|
|
486
|
+
['db.shipwrecks.aggregate([ { $project'],
|
|
487
|
+
i,
|
|
488
|
+
]);
|
|
416
489
|
});
|
|
417
490
|
|
|
418
|
-
it('does not fail when the server_version is not specified', async()
|
|
491
|
+
it('does not fail when the server_version is not specified', async function () {
|
|
419
492
|
const i = 'db.shipwrecks.aggregate([ { $proj';
|
|
420
|
-
expect(
|
|
421
|
-
|
|
493
|
+
expect(
|
|
494
|
+
await completer(emptyConnectionInfoParams as any, i)
|
|
495
|
+
).to.deep.equal([['db.shipwrecks.aggregate([ { $project'], i]);
|
|
422
496
|
});
|
|
423
497
|
});
|
|
424
498
|
|
|
425
|
-
context('when context is a collection query', ()
|
|
426
|
-
it('returns all suggestions', async()
|
|
499
|
+
context('when context is a collection query', function () {
|
|
500
|
+
it('returns all suggestions', async function () {
|
|
427
501
|
const i = 'db.shipwrecks.find({ ';
|
|
428
|
-
expect((await completer(standalone440, i))[0]).to.include.members(
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
502
|
+
expect((await completer(standalone440, i))[0]).to.include.members([
|
|
503
|
+
'db.shipwrecks.find({ $all',
|
|
504
|
+
'db.shipwrecks.find({ $and',
|
|
505
|
+
'db.shipwrecks.find({ $bitsAllClear',
|
|
506
|
+
'db.shipwrecks.find({ $bitsAllSet',
|
|
507
|
+
'db.shipwrecks.find({ $bitsAnyClear',
|
|
508
|
+
'db.shipwrecks.find({ $bitsAnySet',
|
|
509
|
+
'db.shipwrecks.find({ $comment',
|
|
510
|
+
'db.shipwrecks.find({ $elemMatch',
|
|
511
|
+
'db.shipwrecks.find({ $eq',
|
|
512
|
+
'db.shipwrecks.find({ $exists',
|
|
513
|
+
'db.shipwrecks.find({ $expr',
|
|
514
|
+
'db.shipwrecks.find({ $geoIntersects',
|
|
515
|
+
'db.shipwrecks.find({ $geoWithin',
|
|
516
|
+
'db.shipwrecks.find({ $gt',
|
|
517
|
+
'db.shipwrecks.find({ $gte',
|
|
518
|
+
'db.shipwrecks.find({ $in',
|
|
519
|
+
'db.shipwrecks.find({ $jsonSchema',
|
|
520
|
+
'db.shipwrecks.find({ $lt',
|
|
521
|
+
'db.shipwrecks.find({ $lte',
|
|
522
|
+
'db.shipwrecks.find({ $mod',
|
|
523
|
+
'db.shipwrecks.find({ $ne',
|
|
524
|
+
'db.shipwrecks.find({ $near',
|
|
525
|
+
'db.shipwrecks.find({ $nearSphere',
|
|
526
|
+
'db.shipwrecks.find({ $nin',
|
|
527
|
+
'db.shipwrecks.find({ $not',
|
|
528
|
+
'db.shipwrecks.find({ $nor',
|
|
529
|
+
'db.shipwrecks.find({ $or',
|
|
530
|
+
'db.shipwrecks.find({ $regex',
|
|
531
|
+
'db.shipwrecks.find({ $size',
|
|
532
|
+
'db.shipwrecks.find({ $slice',
|
|
533
|
+
'db.shipwrecks.find({ $text',
|
|
534
|
+
'db.shipwrecks.find({ $type',
|
|
535
|
+
'db.shipwrecks.find({ $where',
|
|
536
|
+
'db.shipwrecks.find({ Code',
|
|
537
|
+
'db.shipwrecks.find({ ObjectId',
|
|
538
|
+
'db.shipwrecks.find({ Binary',
|
|
539
|
+
'db.shipwrecks.find({ DBRef',
|
|
540
|
+
'db.shipwrecks.find({ Timestamp',
|
|
541
|
+
'db.shipwrecks.find({ NumberInt',
|
|
542
|
+
'db.shipwrecks.find({ NumberLong',
|
|
543
|
+
'db.shipwrecks.find({ NumberDecimal',
|
|
544
|
+
'db.shipwrecks.find({ MaxKey',
|
|
545
|
+
'db.shipwrecks.find({ MinKey',
|
|
546
|
+
'db.shipwrecks.find({ ISODate',
|
|
547
|
+
'db.shipwrecks.find({ RegExp',
|
|
548
|
+
]);
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
it('has several matches', async function () {
|
|
477
552
|
const i = 'db.bios.find({ birth: { $g';
|
|
478
553
|
expect(await completer(standalone440, i)).to.deep.equal([
|
|
479
554
|
[
|
|
@@ -481,225 +556,253 @@ describe('completer.completer', () => {
|
|
|
481
556
|
'db.bios.find({ birth: { $geoWithin',
|
|
482
557
|
'db.bios.find({ birth: { $gt',
|
|
483
558
|
'db.bios.find({ birth: { $gte',
|
|
484
|
-
],
|
|
559
|
+
],
|
|
560
|
+
i,
|
|
561
|
+
]);
|
|
485
562
|
});
|
|
486
563
|
|
|
487
|
-
it('does not have a match', async()
|
|
564
|
+
it('does not have a match', async function () {
|
|
488
565
|
const i = 'db.bios.find({ field: { $cat';
|
|
489
566
|
expect(await completer(standalone440, i)).to.deep.equal([[], i]);
|
|
490
567
|
});
|
|
491
568
|
|
|
492
|
-
it('matches an aggregation stage', async()
|
|
569
|
+
it('matches an aggregation stage', async function () {
|
|
493
570
|
const i = 'db.bios.find({ field: { $exis';
|
|
494
571
|
expect(await completer(standalone440, i)).to.deep.equal([
|
|
495
|
-
[
|
|
572
|
+
['db.bios.find({ field: { $exists'],
|
|
573
|
+
i,
|
|
574
|
+
]);
|
|
496
575
|
});
|
|
497
576
|
});
|
|
498
577
|
|
|
499
|
-
context('when context is collections and collection cursor', ()
|
|
500
|
-
it('matches a collection cursor command', async()
|
|
578
|
+
context('when context is collections and collection cursor', function () {
|
|
579
|
+
it('matches a collection cursor command', async function () {
|
|
501
580
|
const i = 'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).for';
|
|
502
581
|
expect(await completer(standalone440, i)).to.deep.equal([
|
|
503
|
-
['db.shipwrecks.find({feature_type: "Wrecks - Visible"}).forEach'],
|
|
582
|
+
['db.shipwrecks.find({feature_type: "Wrecks - Visible"}).forEach'],
|
|
583
|
+
i,
|
|
584
|
+
]);
|
|
504
585
|
});
|
|
505
586
|
|
|
506
|
-
it('returns all suggestions running on 4.4.0 version', async()
|
|
587
|
+
it('returns all suggestions running on 4.4.0 version', async function () {
|
|
507
588
|
const i = 'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).';
|
|
508
589
|
|
|
509
590
|
const result = [
|
|
510
|
-
'db.shipwrecks.find({feature_type:
|
|
511
|
-
'db.shipwrecks.find({feature_type:
|
|
512
|
-
'db.shipwrecks.find({feature_type:
|
|
513
|
-
'db.shipwrecks.find({feature_type:
|
|
514
|
-
'db.shipwrecks.find({feature_type:
|
|
515
|
-
'db.shipwrecks.find({feature_type:
|
|
516
|
-
'db.shipwrecks.find({feature_type:
|
|
517
|
-
'db.shipwrecks.find({feature_type:
|
|
518
|
-
'db.shipwrecks.find({feature_type:
|
|
519
|
-
'db.shipwrecks.find({feature_type:
|
|
520
|
-
'db.shipwrecks.find({feature_type:
|
|
521
|
-
'db.shipwrecks.find({feature_type:
|
|
522
|
-
'db.shipwrecks.find({feature_type:
|
|
523
|
-
'db.shipwrecks.find({feature_type:
|
|
524
|
-
'db.shipwrecks.find({feature_type:
|
|
525
|
-
'db.shipwrecks.find({feature_type:
|
|
526
|
-
'db.shipwrecks.find({feature_type:
|
|
527
|
-
'db.shipwrecks.find({feature_type:
|
|
528
|
-
'db.shipwrecks.find({feature_type:
|
|
529
|
-
'db.shipwrecks.find({feature_type:
|
|
530
|
-
'db.shipwrecks.find({feature_type:
|
|
531
|
-
'db.shipwrecks.find({feature_type:
|
|
532
|
-
'db.shipwrecks.find({feature_type:
|
|
533
|
-
'db.shipwrecks.find({feature_type:
|
|
534
|
-
'db.shipwrecks.find({feature_type:
|
|
535
|
-
'db.shipwrecks.find({feature_type:
|
|
536
|
-
'db.shipwrecks.find({feature_type:
|
|
537
|
-
'db.shipwrecks.find({feature_type:
|
|
538
|
-
'db.shipwrecks.find({feature_type:
|
|
539
|
-
'db.shipwrecks.find({feature_type:
|
|
540
|
-
'db.shipwrecks.find({feature_type:
|
|
541
|
-
'db.shipwrecks.find({feature_type:
|
|
542
|
-
'db.shipwrecks.find({feature_type:
|
|
591
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).allowPartialResults',
|
|
592
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).batchSize',
|
|
593
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).close',
|
|
594
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).collation',
|
|
595
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).comment',
|
|
596
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).explain',
|
|
597
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).forEach',
|
|
598
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).hasNext',
|
|
599
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).hint',
|
|
600
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).isClosed',
|
|
601
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).isExhausted',
|
|
602
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).itcount',
|
|
603
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).limit',
|
|
604
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).map',
|
|
605
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).max',
|
|
606
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).maxTimeMS',
|
|
607
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).maxAwaitTimeMS',
|
|
608
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).min',
|
|
609
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).next',
|
|
610
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).noCursorTimeout',
|
|
611
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).oplogReplay',
|
|
612
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).projection',
|
|
613
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).readPref',
|
|
614
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).returnKey',
|
|
615
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).size',
|
|
616
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).skip',
|
|
617
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).sort',
|
|
618
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).tailable',
|
|
619
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).toArray',
|
|
620
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).pretty',
|
|
621
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).showRecordId',
|
|
622
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).objsLeftInBatch',
|
|
623
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).readConcern',
|
|
543
624
|
];
|
|
544
625
|
|
|
545
626
|
expect((await completer(standalone440, i))[0]).to.include.members(result);
|
|
546
627
|
});
|
|
547
628
|
|
|
548
|
-
it('returns all suggestions matching 3.0.0 version', async()
|
|
629
|
+
it('returns all suggestions matching 3.0.0 version', async function () {
|
|
549
630
|
const i = 'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).';
|
|
550
631
|
|
|
551
632
|
const result = [
|
|
552
|
-
'db.shipwrecks.find({feature_type:
|
|
553
|
-
'db.shipwrecks.find({feature_type:
|
|
554
|
-
'db.shipwrecks.find({feature_type:
|
|
555
|
-
'db.shipwrecks.find({feature_type:
|
|
556
|
-
'db.shipwrecks.find({feature_type:
|
|
557
|
-
'db.shipwrecks.find({feature_type:
|
|
558
|
-
'db.shipwrecks.find({feature_type:
|
|
559
|
-
'db.shipwrecks.find({feature_type:
|
|
560
|
-
'db.shipwrecks.find({feature_type:
|
|
561
|
-
'db.shipwrecks.find({feature_type:
|
|
562
|
-
'db.shipwrecks.find({feature_type:
|
|
563
|
-
'db.shipwrecks.find({feature_type:
|
|
564
|
-
'db.shipwrecks.find({feature_type:
|
|
565
|
-
'db.shipwrecks.find({feature_type:
|
|
566
|
-
'db.shipwrecks.find({feature_type:
|
|
567
|
-
'db.shipwrecks.find({feature_type:
|
|
568
|
-
'db.shipwrecks.find({feature_type:
|
|
569
|
-
'db.shipwrecks.find({feature_type:
|
|
570
|
-
'db.shipwrecks.find({feature_type:
|
|
571
|
-
'db.shipwrecks.find({feature_type:
|
|
572
|
-
'db.shipwrecks.find({feature_type:
|
|
573
|
-
'db.shipwrecks.find({feature_type:
|
|
574
|
-
'db.shipwrecks.find({feature_type:
|
|
575
|
-
'db.shipwrecks.find({feature_type:
|
|
576
|
-
'db.shipwrecks.find({feature_type:
|
|
633
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).addOption',
|
|
634
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).allowPartialResults',
|
|
635
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).batchSize',
|
|
636
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).close',
|
|
637
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).explain',
|
|
638
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).forEach',
|
|
639
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).hasNext',
|
|
640
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).hint',
|
|
641
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).isClosed',
|
|
642
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).isExhausted',
|
|
643
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).itcount',
|
|
644
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).limit',
|
|
645
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).map',
|
|
646
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).max',
|
|
647
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).maxTimeMS',
|
|
648
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).min',
|
|
649
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).next',
|
|
650
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).noCursorTimeout',
|
|
651
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).oplogReplay',
|
|
652
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).projection',
|
|
653
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).readPref',
|
|
654
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).size',
|
|
655
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).skip',
|
|
656
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).sort',
|
|
657
|
+
'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).toArray',
|
|
577
658
|
];
|
|
578
659
|
|
|
579
660
|
expect((await completer(standalone300, i))[0]).to.include.members(result);
|
|
580
661
|
});
|
|
581
662
|
|
|
582
|
-
it('does not have a match', async()
|
|
663
|
+
it('does not have a match', async function () {
|
|
583
664
|
const i = 'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).gre';
|
|
584
665
|
expect(await completer(standalone440, i)).to.deep.equal([[], i]);
|
|
585
666
|
});
|
|
586
667
|
|
|
587
|
-
it('has several matches', async()
|
|
668
|
+
it('has several matches', async function () {
|
|
588
669
|
const i = 'db.shipwrecks.find({feature_type: "Wrecks - Visible"}).cl';
|
|
589
670
|
expect(await completer(standalone440, i)).to.deep.equal([
|
|
590
|
-
[
|
|
591
|
-
|
|
592
|
-
|
|
671
|
+
['db.shipwrecks.find({feature_type: "Wrecks - Visible"}).close'],
|
|
672
|
+
i,
|
|
673
|
+
]);
|
|
593
674
|
});
|
|
594
675
|
|
|
595
|
-
it('does not match if it is not .find or .aggregate', async()
|
|
676
|
+
it('does not match if it is not .find or .aggregate', async function () {
|
|
596
677
|
const i = 'db.shipwrecks.moo({feature_type: "Wrecks - Visible"}).';
|
|
597
678
|
expect(await completer(standalone440, i)).to.deep.equal([[], i]);
|
|
598
679
|
});
|
|
599
680
|
});
|
|
600
681
|
|
|
601
|
-
context('for shell commands', ()
|
|
602
|
-
it('completes partial commands', async()
|
|
682
|
+
context('for shell commands', function () {
|
|
683
|
+
it('completes partial commands', async function () {
|
|
603
684
|
const i = 'sho';
|
|
604
|
-
expect(await completer(noParams, i))
|
|
605
|
-
.to.deep.equal([['show'], i]);
|
|
685
|
+
expect(await completer(noParams, i)).to.deep.equal([['show'], i]);
|
|
606
686
|
});
|
|
607
687
|
|
|
608
|
-
it('completes partial commands', async()
|
|
688
|
+
it('completes partial commands', async function () {
|
|
609
689
|
const i = 'show';
|
|
610
690
|
const result = await completer(noParams, i);
|
|
611
691
|
expect(result[0]).to.contain('show databases');
|
|
612
692
|
});
|
|
613
693
|
|
|
614
|
-
it('completes show databases', async()
|
|
694
|
+
it('completes show databases', async function () {
|
|
615
695
|
const i = 'show d';
|
|
616
|
-
expect(await completer(noParams, i))
|
|
617
|
-
|
|
696
|
+
expect(await completer(noParams, i)).to.deep.equal([
|
|
697
|
+
['show databases'],
|
|
698
|
+
i,
|
|
699
|
+
'exclusive',
|
|
700
|
+
]);
|
|
618
701
|
});
|
|
619
702
|
|
|
620
|
-
it('completes show profile', async()
|
|
703
|
+
it('completes show profile', async function () {
|
|
621
704
|
const i = 'show pr';
|
|
622
|
-
expect(await completer(noParams, i))
|
|
623
|
-
|
|
705
|
+
expect(await completer(noParams, i)).to.deep.equal([
|
|
706
|
+
['show profile'],
|
|
707
|
+
i,
|
|
708
|
+
'exclusive',
|
|
709
|
+
]);
|
|
624
710
|
});
|
|
625
711
|
|
|
626
|
-
it('completes use db with no space', async()
|
|
712
|
+
it('completes use db with no space', async function () {
|
|
627
713
|
databases = ['db1', 'db2'];
|
|
628
714
|
const i = 'use';
|
|
629
|
-
expect(await completer(noParams, i))
|
|
630
|
-
|
|
715
|
+
expect(await completer(noParams, i)).to.deep.equal([
|
|
716
|
+
['use db1', 'use db2'],
|
|
717
|
+
i,
|
|
718
|
+
'exclusive',
|
|
719
|
+
]);
|
|
631
720
|
});
|
|
632
721
|
|
|
633
|
-
it('completes use db with a space', async()
|
|
722
|
+
it('completes use db with a space', async function () {
|
|
634
723
|
databases = ['db1', 'db2'];
|
|
635
724
|
const i = 'use ';
|
|
636
|
-
expect(await completer(noParams, i))
|
|
637
|
-
|
|
725
|
+
expect(await completer(noParams, i)).to.deep.equal([
|
|
726
|
+
['use db1', 'use db2'],
|
|
727
|
+
i,
|
|
728
|
+
'exclusive',
|
|
729
|
+
]);
|
|
638
730
|
});
|
|
639
731
|
|
|
640
|
-
it('completes use db with single database and no space', async()
|
|
732
|
+
it('completes use db with single database and no space', async function () {
|
|
641
733
|
databases = ['db1'];
|
|
642
734
|
const i = 'use';
|
|
643
|
-
expect(await completer(noParams, i))
|
|
644
|
-
|
|
735
|
+
expect(await completer(noParams, i)).to.deep.equal([
|
|
736
|
+
['use db1'],
|
|
737
|
+
i,
|
|
738
|
+
'exclusive',
|
|
739
|
+
]);
|
|
645
740
|
});
|
|
646
741
|
|
|
647
|
-
it('completes use db with single database and space', async()
|
|
742
|
+
it('completes use db with single database and space', async function () {
|
|
648
743
|
databases = ['db1'];
|
|
649
744
|
const i = 'use ';
|
|
650
|
-
expect(await completer(noParams, i))
|
|
651
|
-
|
|
745
|
+
expect(await completer(noParams, i)).to.deep.equal([
|
|
746
|
+
['use db1'],
|
|
747
|
+
i,
|
|
748
|
+
'exclusive',
|
|
749
|
+
]);
|
|
652
750
|
});
|
|
653
751
|
|
|
654
|
-
it('does not try to complete over-long commands', async()
|
|
752
|
+
it('does not try to complete over-long commands', async function () {
|
|
655
753
|
databases = ['db1', 'db2'];
|
|
656
754
|
const i = 'use db1 d';
|
|
657
|
-
expect(await completer(noParams, i))
|
|
658
|
-
.to.deep.equal([[], i, 'exclusive']);
|
|
755
|
+
expect(await completer(noParams, i)).to.deep.equal([[], i, 'exclusive']);
|
|
659
756
|
});
|
|
660
757
|
|
|
661
|
-
it('completes commands like exit', async()
|
|
758
|
+
it('completes commands like exit', async function () {
|
|
662
759
|
const i = 'exi';
|
|
663
|
-
expect(await completer(noParams, i))
|
|
664
|
-
.to.deep.equal([['exit'], i]);
|
|
760
|
+
expect(await completer(noParams, i)).to.deep.equal([['exit'], i]);
|
|
665
761
|
});
|
|
666
762
|
|
|
667
|
-
it('completes with multiple spaces', async()
|
|
763
|
+
it('completes with multiple spaces', async function () {
|
|
668
764
|
const i = 'show datab';
|
|
669
|
-
expect(await completer(noParams, i))
|
|
670
|
-
|
|
765
|
+
expect(await completer(noParams, i)).to.deep.equal([
|
|
766
|
+
['show databases'],
|
|
767
|
+
i,
|
|
768
|
+
'exclusive',
|
|
769
|
+
]);
|
|
671
770
|
});
|
|
672
771
|
});
|
|
673
772
|
|
|
674
|
-
context('with apiStrict', ()
|
|
675
|
-
it('completes supported methods like db.test.findOneAndReplace', async()
|
|
773
|
+
context('with apiStrict', function () {
|
|
774
|
+
it('completes supported methods like db.test.findOneAndReplace', async function () {
|
|
676
775
|
const i = 'db.test.findOneAndR';
|
|
677
|
-
expect(await completer(apiStrictParams, i))
|
|
678
|
-
|
|
776
|
+
expect(await completer(apiStrictParams, i)).to.deep.equal([
|
|
777
|
+
['db.test.findOneAndReplace'],
|
|
778
|
+
i,
|
|
779
|
+
]);
|
|
679
780
|
});
|
|
680
781
|
|
|
681
|
-
it('completes common methods like db.test.getName', async()
|
|
782
|
+
it('completes common methods like db.test.getName', async function () {
|
|
682
783
|
const i = 'db.test.getNam';
|
|
683
|
-
expect(await completer(apiStrictParams, i))
|
|
684
|
-
|
|
784
|
+
expect(await completer(apiStrictParams, i)).to.deep.equal([
|
|
785
|
+
['db.test.getName'],
|
|
786
|
+
i,
|
|
787
|
+
]);
|
|
685
788
|
});
|
|
686
789
|
|
|
687
|
-
it('does not complete unsupported methods like db.test.renameCollection', async()
|
|
790
|
+
it('does not complete unsupported methods like db.test.renameCollection', async function () {
|
|
688
791
|
const i = 'db.test.renameC';
|
|
689
|
-
expect(await completer(apiStrictParams, i))
|
|
690
|
-
.to.deep.equal([[], i]);
|
|
792
|
+
expect(await completer(apiStrictParams, i)).to.deep.equal([[], i]);
|
|
691
793
|
});
|
|
692
794
|
|
|
693
|
-
it('completes supported aggregation stages', async()
|
|
795
|
+
it('completes supported aggregation stages', async function () {
|
|
694
796
|
const i = 'db.test.aggregate([{$mat';
|
|
695
|
-
expect(await completer(apiStrictParams, i))
|
|
696
|
-
|
|
797
|
+
expect(await completer(apiStrictParams, i)).to.deep.equal([
|
|
798
|
+
['db.test.aggregate([{$match'],
|
|
799
|
+
i,
|
|
800
|
+
]);
|
|
697
801
|
});
|
|
698
802
|
|
|
699
|
-
it('does not complete unsupported aggregation stages', async()
|
|
803
|
+
it('does not complete unsupported aggregation stages', async function () {
|
|
700
804
|
const i = 'db.test.aggregate([{$indexSta';
|
|
701
|
-
expect(await completer(apiStrictParams, i))
|
|
702
|
-
.to.deep.equal([[], i]);
|
|
805
|
+
expect(await completer(apiStrictParams, i)).to.deep.equal([[], i]);
|
|
703
806
|
});
|
|
704
807
|
});
|
|
705
808
|
});
|