@@ -7,6 +7,7 @@ let collections: string[];
7
7
let databases : string [ ] ;
8
8
const standalone440 = {
9
9
topology : ( ) => Topologies . Standalone ,
10
+ apiVersionInfo : ( ) => undefined ,
10
11
connectionInfo : ( ) => ( {
11
12
is_atlas : false ,
12
13
is_data_lake : false ,
@@ -15,8 +16,16 @@ const standalone440 = {
15
16
getCollectionCompletionsForCurrentDb : ( ) => collections ,
16
17
getDatabaseCompletions : ( ) => databases
17
18
} ;
19
+ const apiStrictParams = {
20
+ topology : ( ) => Topologies . Standalone ,
21
+ apiVersionInfo : ( ) => ( { version : '1' , strict : true , deprecationErrors : false } ) ,
22
+ connectionInfo : ( ) => undefined ,
23
+ getCollectionCompletionsForCurrentDb : ( ) => collections ,
24
+ getDatabaseCompletions : ( ) => databases
25
+ } ;
18
26
const sharded440 = {
19
27
topology : ( ) => Topologies . Sharded ,
28
+ apiVersionInfo : ( ) => undefined ,
20
29
connectionInfo : ( ) => ( {
21
30
is_atlas : false ,
22
31
is_data_lake : false ,
@@ -28,6 +37,7 @@ const sharded440 = {
28
37
29
38
const standalone300 = {
30
39
topology : ( ) => Topologies . Standalone ,
40
+ apiVersionInfo : ( ) => undefined ,
31
41
connectionInfo : ( ) => ( {
32
42
is_atlas : false ,
33
43
is_data_lake : false ,
@@ -38,6 +48,7 @@ const standalone300 = {
38
48
} ;
39
49
const datalake440 = {
40
50
topology : ( ) => Topologies . Sharded ,
51
+ apiVersionInfo : ( ) => undefined ,
41
52
connectionInfo : ( ) => ( {
42
53
is_atlas : true ,
43
54
is_data_lake : true ,
@@ -49,13 +60,15 @@ const datalake440 = {
49
60
50
61
const noParams = {
51
62
topology : ( ) => Topologies . Standalone ,
63
+ apiVersionInfo : ( ) => undefined ,
52
64
connectionInfo : ( ) => undefined ,
53
65
getCollectionCompletionsForCurrentDb : ( ) => collections ,
54
66
getDatabaseCompletions : ( ) => databases
55
67
} ;
56
68
57
69
const emptyConnectionInfoParams = {
58
70
topology : ( ) => Topologies . Standalone ,
71
+ apiVersionInfo : ( ) => undefined ,
59
72
connectionInfo : ( ) => ( { } ) ,
60
73
getCollectionCompletionsForCurrentDb : ( ) => collections ,
61
74
getDatabaseCompletions : ( ) => databases
@@ -558,4 +571,36 @@ describe('completer.completer', () => {
558
571
. to . deep . equal ( [ [ 'show databases' ] , i , 'exclusive' ] ) ;
559
572
} ) ;
560
573
} ) ;
574
+
575
+ context ( 'with apiStrict' , ( ) => {
576
+ it ( 'completes supported methods like db.test.findOneAndReplace' , async ( ) => {
577
+ const i = 'db.test.findOneAndR' ;
578
+ expect ( await completer ( apiStrictParams , i ) )
579
+ . to . deep . equal ( [ [ 'db.test.findOneAndReplace' ] , i ] ) ;
580
+ } ) ;
581
+
582
+ it ( 'completes common methods like db.test.getName' , async ( ) => {
583
+ const i = 'db.test.getNam' ;
584
+ expect ( await completer ( apiStrictParams , i ) )
585
+ . to . deep . equal ( [ [ 'db.test.getName' ] , i ] ) ;
586
+ } ) ;
587
+
588
+ it ( 'does not complete unsupported methods like db.test.renameCollection' , async ( ) => {
589
+ const i = 'db.test.renameC' ;
590
+ expect ( await completer ( apiStrictParams , i ) )
591
+ . to . deep . equal ( [ [ ] , i ] ) ;
592
+ } ) ;
593
+
594
+ it ( 'completes supported aggregation stages' , async ( ) => {
595
+ const i = 'db.test.aggregate([{$mat' ;
596
+ expect ( await completer ( apiStrictParams , i ) )
597
+ . to . deep . equal ( [ [ 'db.test.aggregate([{$match' ] , i ] ) ;
598
+ } ) ;
599
+
600
+ it ( 'does not complete unsupported aggregation stages' , async ( ) => {
601
+ const i = 'db.test.aggregate([{$indexSta' ;
602
+ expect ( await completer ( apiStrictParams , i ) )
603
+ . to . deep . equal ( [ [ ] , i ] ) ;
604
+ } ) ;
605
+ } ) ;
561
606
} ) ;
0 commit comments