11import * as assert from 'assert' ;
22import * as vscode from 'vscode' ;
3- import { afterEach } from 'mocha' ;
3+ import { afterEach , beforeEach } from 'mocha' ;
44import * as sinon from 'sinon' ;
55import Connection = require( 'mongodb-connection-model/lib/model' ) ;
66
@@ -26,6 +26,11 @@ suite('Connection Controller Test Suite', () => {
2626 const mockExtensionContext = new TestExtensionContext ( ) ;
2727 const mockStorageController = new StorageController ( mockExtensionContext ) ;
2828
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+ } ) ;
2934 afterEach ( ( ) => {
3035 // Reset our mock extension's state.
3136 mockExtensionContext . _workspaceState = { } ;
@@ -68,7 +73,11 @@ suite('Connection Controller Test Suite', () => {
6873 ) ;
6974 const dataService = testConnectionController . getActiveDataService ( ) ;
7075 assert ( dataService !== null ) ;
71- assert ( testConnectionController . _activeConnectionModel ?. appname . startsWith ( 'mongodb-vscode' ) ) ;
76+ assert (
77+ testConnectionController . _activeConnectionModel ?. appname . startsWith (
78+ 'mongodb-vscode'
79+ )
80+ ) ;
7281 assert ( testConnectionController . isCurrentlyConnected ( ) ) ;
7382 } )
7483 . then ( done , done ) ;
@@ -484,7 +493,7 @@ suite('Connection Controller Test Suite', () => {
484493 assert (
485494 Object . keys ( connections ) . length === 4 ,
486495 `Expected 4 connection configurations found ${
487- Object . keys ( connections ) . length
496+ Object . keys ( connections ) . length
488497 } `
489498 ) ;
490499 assert (
@@ -493,7 +502,7 @@ suite('Connection Controller Test Suite', () => {
493502 ) ;
494503 assert (
495504 Object . keys ( connections ) . includes ( 'testWorkspaceConnectionModel2' ) ===
496- true ,
505+ true ,
497506 "Expected connection configurations to include 'testWorkspaceConnectionModel2'"
498507 ) ;
499508 assert (
@@ -502,7 +511,7 @@ suite('Connection Controller Test Suite', () => {
502511 ) ;
503512 assert (
504513 connections . testGlobalConnectionModel2 . driverUrl ===
505- 'testGlobalConnectionModel2DriverUrl' ,
514+ 'testGlobalConnectionModel2DriverUrl' ,
506515 "Expected loaded connection to include driver url 'testGlobalConnectionModel2DriverUrl'"
507516 ) ;
508517 assert (
@@ -540,7 +549,7 @@ suite('Connection Controller Test Suite', () => {
540549 assert (
541550 Object . keys ( globalStoreConnections ) . length === 1 ,
542551 `Expected global store connections to have 1 connection found ${
543- Object . keys ( globalStoreConnections ) . length
552+ Object . keys ( globalStoreConnections ) . length
544553 } `
545554 ) ;
546555 const id = Object . keys ( globalStoreConnections ) [ 0 ] ;
@@ -588,7 +597,7 @@ suite('Connection Controller Test Suite', () => {
588597 assert (
589598 Object . keys ( workspaceStoreConnections ) . length === 1 ,
590599 `Expected workspace store connections to have 1 connection found ${
591- Object . keys ( workspaceStoreConnections ) . length
600+ Object . keys ( workspaceStoreConnections ) . length
592601 } `
593602 ) ;
594603 const id = Object . keys ( workspaceStoreConnections ) [ 0 ] ;
@@ -669,7 +678,7 @@ suite('Connection Controller Test Suite', () => {
669678 assert (
670679 Object . keys ( workspaceStoreConnections ) . length === 1 ,
671680 `Expected workspace store connections to have 1 connection found ${
672- Object . keys ( workspaceStoreConnections ) . length
681+ Object . keys ( workspaceStoreConnections ) . length
673682 } `
674683 ) ;
675684
@@ -687,7 +696,7 @@ suite('Connection Controller Test Suite', () => {
687696 assert (
688697 testConnectionController . getSavedConnections ( ) . length === 1 ,
689698 `Expected 1 connection config, found ${
690- testConnectionController . getSavedConnections ( ) . length
699+ testConnectionController . getSavedConnections ( ) . length
691700 } .`
692701 ) ;
693702 const id = testConnectionController . getSavedConnections ( ) [ 0 ] . id ;
@@ -839,7 +848,7 @@ suite('Connection Controller Test Suite', () => {
839848 assert (
840849 Object . keys ( workspaceStoreConnections ) . length === 1 ,
841850 `Expected workspace store connections to have 1 connection found ${
842- Object . keys ( workspaceStoreConnections ) . length
851+ Object . keys ( workspaceStoreConnections ) . length
843852 } `
844853 ) ;
845854
@@ -855,7 +864,7 @@ suite('Connection Controller Test Suite', () => {
855864 assert (
856865 Object . keys ( postWorkspaceStoreConnections ) . length === 0 ,
857866 `Expected workspace store connections to have 0 connections found ${
858- Object . keys ( postWorkspaceStoreConnections ) . length
867+ Object . keys ( postWorkspaceStoreConnections ) . length
859868 } `
860869 ) ;
861870 } )
@@ -889,7 +898,7 @@ suite('Connection Controller Test Suite', () => {
889898 assert (
890899 Object . keys ( globalStoreConnections ) . length === 1 ,
891900 `Expected workspace store connections to have 1 connection found ${
892- Object . keys ( globalStoreConnections ) . length
901+ Object . keys ( globalStoreConnections ) . length
893902 } `
894903 ) ;
895904
@@ -903,7 +912,7 @@ suite('Connection Controller Test Suite', () => {
903912 assert (
904913 Object . keys ( postGlobalStoreConnections ) . length === 0 ,
905914 `Expected global store connections to have 0 connections found ${
906- Object . keys ( postGlobalStoreConnections ) . length
915+ Object . keys ( postGlobalStoreConnections ) . length
907916 } `
908917 ) ;
909918 } ) ;
@@ -939,7 +948,7 @@ suite('Connection Controller Test Suite', () => {
939948 assert (
940949 Object . keys ( workspaceStoreConnections ) . length === 1 ,
941950 `Expected workspace store connections to have 1 connection found ${
942- Object . keys ( workspaceStoreConnections ) . length
951+ Object . keys ( workspaceStoreConnections ) . length
943952 } `
944953 ) ;
945954 const connectionId =
@@ -974,7 +983,7 @@ suite('Connection Controller Test Suite', () => {
974983 testConnectionController . getSavedConnections ( )
975984 . length === 1 ,
976985 `Expected 1 connection config, found ${
977- testConnectionController . getSavedConnections ( ) . length
986+ testConnectionController . getSavedConnections ( ) . length
978987 } .`
979988 ) ;
980989 const id = testConnectionController . getSavedConnections ( ) [ 0 ]
0 commit comments