1
1
import * as assert from 'assert' ;
2
2
import * as vscode from 'vscode' ;
3
- import { afterEach } from 'mocha' ;
3
+ import { afterEach , beforeEach } from 'mocha' ;
4
4
import * as sinon from 'sinon' ;
5
5
import Connection = require( 'mongodb-connection-model/lib/model' ) ;
6
6
@@ -26,6 +26,11 @@ suite('Connection Controller Test Suite', () => {
26
26
const mockExtensionContext = new TestExtensionContext ( ) ;
27
27
const mockStorageController = new StorageController ( mockExtensionContext ) ;
28
28
29
+ beforeEach ( ( ) => {
30
+ // Here we stub the showInformationMessage process because it is too much
31
+ // for the render process and leads to crashes while testing.
32
+ sinon . replace ( vscode . window , 'showInformationMessage' , sinon . stub ( ) ) ;
33
+ } ) ;
29
34
afterEach ( ( ) => {
30
35
// Reset our mock extension's state.
31
36
mockExtensionContext . _workspaceState = { } ;
@@ -68,7 +73,11 @@ suite('Connection Controller Test Suite', () => {
68
73
) ;
69
74
const dataService = testConnectionController . getActiveDataService ( ) ;
70
75
assert ( dataService !== null ) ;
71
- assert ( testConnectionController . _activeConnectionModel ?. appname . startsWith ( 'mongodb-vscode' ) ) ;
76
+ assert (
77
+ testConnectionController . _activeConnectionModel ?. appname . startsWith (
78
+ 'mongodb-vscode'
79
+ )
80
+ ) ;
72
81
assert ( testConnectionController . isCurrentlyConnected ( ) ) ;
73
82
} )
74
83
. then ( done , done ) ;
@@ -484,7 +493,7 @@ suite('Connection Controller Test Suite', () => {
484
493
assert (
485
494
Object . keys ( connections ) . length === 4 ,
486
495
`Expected 4 connection configurations found ${
487
- Object . keys ( connections ) . length
496
+ Object . keys ( connections ) . length
488
497
} `
489
498
) ;
490
499
assert (
@@ -493,7 +502,7 @@ suite('Connection Controller Test Suite', () => {
493
502
) ;
494
503
assert (
495
504
Object . keys ( connections ) . includes ( 'testWorkspaceConnectionModel2' ) ===
496
- true ,
505
+ true ,
497
506
"Expected connection configurations to include 'testWorkspaceConnectionModel2'"
498
507
) ;
499
508
assert (
@@ -502,7 +511,7 @@ suite('Connection Controller Test Suite', () => {
502
511
) ;
503
512
assert (
504
513
connections . testGlobalConnectionModel2 . driverUrl ===
505
- 'testGlobalConnectionModel2DriverUrl' ,
514
+ 'testGlobalConnectionModel2DriverUrl' ,
506
515
"Expected loaded connection to include driver url 'testGlobalConnectionModel2DriverUrl'"
507
516
) ;
508
517
assert (
@@ -540,7 +549,7 @@ suite('Connection Controller Test Suite', () => {
540
549
assert (
541
550
Object . keys ( globalStoreConnections ) . length === 1 ,
542
551
`Expected global store connections to have 1 connection found ${
543
- Object . keys ( globalStoreConnections ) . length
552
+ Object . keys ( globalStoreConnections ) . length
544
553
} `
545
554
) ;
546
555
const id = Object . keys ( globalStoreConnections ) [ 0 ] ;
@@ -588,7 +597,7 @@ suite('Connection Controller Test Suite', () => {
588
597
assert (
589
598
Object . keys ( workspaceStoreConnections ) . length === 1 ,
590
599
`Expected workspace store connections to have 1 connection found ${
591
- Object . keys ( workspaceStoreConnections ) . length
600
+ Object . keys ( workspaceStoreConnections ) . length
592
601
} `
593
602
) ;
594
603
const id = Object . keys ( workspaceStoreConnections ) [ 0 ] ;
@@ -669,7 +678,7 @@ suite('Connection Controller Test Suite', () => {
669
678
assert (
670
679
Object . keys ( workspaceStoreConnections ) . length === 1 ,
671
680
`Expected workspace store connections to have 1 connection found ${
672
- Object . keys ( workspaceStoreConnections ) . length
681
+ Object . keys ( workspaceStoreConnections ) . length
673
682
} `
674
683
) ;
675
684
@@ -687,7 +696,7 @@ suite('Connection Controller Test Suite', () => {
687
696
assert (
688
697
testConnectionController . getSavedConnections ( ) . length === 1 ,
689
698
`Expected 1 connection config, found ${
690
- testConnectionController . getSavedConnections ( ) . length
699
+ testConnectionController . getSavedConnections ( ) . length
691
700
} .`
692
701
) ;
693
702
const id = testConnectionController . getSavedConnections ( ) [ 0 ] . id ;
@@ -839,7 +848,7 @@ suite('Connection Controller Test Suite', () => {
839
848
assert (
840
849
Object . keys ( workspaceStoreConnections ) . length === 1 ,
841
850
`Expected workspace store connections to have 1 connection found ${
842
- Object . keys ( workspaceStoreConnections ) . length
851
+ Object . keys ( workspaceStoreConnections ) . length
843
852
} `
844
853
) ;
845
854
@@ -855,7 +864,7 @@ suite('Connection Controller Test Suite', () => {
855
864
assert (
856
865
Object . keys ( postWorkspaceStoreConnections ) . length === 0 ,
857
866
`Expected workspace store connections to have 0 connections found ${
858
- Object . keys ( postWorkspaceStoreConnections ) . length
867
+ Object . keys ( postWorkspaceStoreConnections ) . length
859
868
} `
860
869
) ;
861
870
} )
@@ -889,7 +898,7 @@ suite('Connection Controller Test Suite', () => {
889
898
assert (
890
899
Object . keys ( globalStoreConnections ) . length === 1 ,
891
900
`Expected workspace store connections to have 1 connection found ${
892
- Object . keys ( globalStoreConnections ) . length
901
+ Object . keys ( globalStoreConnections ) . length
893
902
} `
894
903
) ;
895
904
@@ -903,7 +912,7 @@ suite('Connection Controller Test Suite', () => {
903
912
assert (
904
913
Object . keys ( postGlobalStoreConnections ) . length === 0 ,
905
914
`Expected global store connections to have 0 connections found ${
906
- Object . keys ( postGlobalStoreConnections ) . length
915
+ Object . keys ( postGlobalStoreConnections ) . length
907
916
} `
908
917
) ;
909
918
} ) ;
@@ -939,7 +948,7 @@ suite('Connection Controller Test Suite', () => {
939
948
assert (
940
949
Object . keys ( workspaceStoreConnections ) . length === 1 ,
941
950
`Expected workspace store connections to have 1 connection found ${
942
- Object . keys ( workspaceStoreConnections ) . length
951
+ Object . keys ( workspaceStoreConnections ) . length
943
952
} `
944
953
) ;
945
954
const connectionId =
@@ -974,7 +983,7 @@ suite('Connection Controller Test Suite', () => {
974
983
testConnectionController . getSavedConnections ( )
975
984
. length === 1 ,
976
985
`Expected 1 connection config, found ${
977
- testConnectionController . getSavedConnections ( ) . length
986
+ testConnectionController . getSavedConnections ( ) . length
978
987
} .`
979
988
) ;
980
989
const id = testConnectionController . getSavedConnections ( ) [ 0 ]
0 commit comments