@@ -209,7 +209,7 @@ describe("core", () => {
209209 beforeEach ( ( ) => {
210210 appendLineSpy = sinon . spy (
211211 vscode . window . createOutputChannel ( "testChannel" ) ,
212- "appendLine" ,
212+ "appendLine"
213213 ) ;
214214 showErrorMessageSpy = sinon . spy ( vscode . window , "showErrorMessage" ) ;
215215 } ) ;
@@ -299,11 +299,16 @@ describe("core", () => {
299299 } ) ;
300300
301301 describe ( "getServers" , ( ) => {
302- let workspaceStub , _getConfigurationStub , getStub : sinon . SinonStub ;
302+ let workspaceStub ,
303+ _getConfigurationStub ,
304+ getStub ,
305+ updateServersStub : sinon . SinonStub ;
303306
304307 beforeEach ( ( ) => {
305308 getStub = sinon . stub ( ) ;
306- _getConfigurationStub = sinon . stub ( ) . returns ( { get : getStub } ) ;
309+ _getConfigurationStub = sinon
310+ . stub ( )
311+ . returns ( { get : getStub , update : sinon . stub ( ) } ) ;
307312 workspaceStub = sinon . stub ( vscode . workspace , "getConfiguration" ) . returns ( {
308313 get : getStub ,
309314 has : function ( _section : string ) : boolean {
@@ -329,22 +334,24 @@ describe("core", () => {
329334 _section : string ,
330335 _value : any ,
331336 _configurationTarget ?: vscode . ConfigurationTarget | boolean | null ,
332- _overrideInLanguage ?: boolean ,
337+ _overrideInLanguage ?: boolean
333338 ) : Thenable < void > {
334339 throw new Error ( "Function not implemented." ) ;
335340 } ,
336341 } ) ;
342+ updateServersStub = sinon . stub ( coreUtils , "updateServers" ) . resolves ( ) ;
337343 } ) ;
338344
339345 afterEach ( ( ) => {
340346 sinon . restore ( ) ;
341347 } ) ;
342348
343- it ( "should return undefined when no servers are configured" , ( ) => {
344- getStub . returns ( undefined ) ;
349+ it ( "should return an empty object when no servers are configured" , ( ) => {
350+ getStub . returns ( { } ) ;
345351 const result = coreUtils . getServers ( ) ;
346352
347- assert . strictEqual ( result , undefined ) ;
353+ assert . ok ( typeof result === "object" ) ;
354+ assert . strictEqual ( Object . keys ( result ) . length , 0 ) ;
348355 assert . ok ( getStub . calledWith ( "kdb.servers" ) ) ;
349356 } ) ;
350357
@@ -510,7 +517,7 @@ describe("core", () => {
510517
511518 coreUtils . getServers ( ) ;
512519
513- assert . ok ( workspaceStub . calledOnce ) ;
520+ assert . ok ( workspaceStub . calledTwice ) ;
514521 assert . ok ( workspaceStub . calledWith ( ) ) ;
515522 } ) ;
516523
@@ -525,11 +532,16 @@ describe("core", () => {
525532 } ) ;
526533
527534 describe ( "getInsights" , ( ) => {
528- let workspaceStub , _getConfigurationStub , getStub : sinon . SinonStub ;
535+ let workspaceStub ,
536+ _getConfigurationStub ,
537+ getStub ,
538+ updateInsightsStub : sinon . SinonStub ;
529539
530540 beforeEach ( ( ) => {
531541 getStub = sinon . stub ( ) ;
532- _getConfigurationStub = sinon . stub ( ) . returns ( { get : getStub } ) ;
542+ _getConfigurationStub = sinon
543+ . stub ( )
544+ . returns ( { get : getStub , update : sinon . stub ( ) } ) ;
533545 workspaceStub = sinon . stub ( vscode . workspace , "getConfiguration" ) . returns ( {
534546 get : getStub ,
535547 has : function ( _section : string ) : boolean {
@@ -551,15 +563,9 @@ describe("core", () => {
551563 | undefined {
552564 throw new Error ( "Function not implemented." ) ;
553565 } ,
554- update : function (
555- _section : string ,
556- _value : any ,
557- _configurationTarget ?: vscode . ConfigurationTarget | boolean | null ,
558- _overrideInLanguage ?: boolean ,
559- ) : Thenable < void > {
560- throw new Error ( "Function not implemented." ) ;
561- } ,
566+ update : sinon . stub ( ) ,
562567 } ) ;
568+ updateInsightsStub = sinon . stub ( coreUtils , "updateInsights" ) . resolves ( ) ;
563569 } ) ;
564570
565571 afterEach ( ( ) => {
@@ -572,7 +578,8 @@ describe("core", () => {
572578
573579 const result = coreUtils . getInsights ( ) ;
574580
575- assert . strictEqual ( result , undefined ) ;
581+ assert . ok ( typeof result === "object" ) ;
582+ assert . strictEqual ( Object . keys ( result ) . length , 0 ) ;
576583 assert . ok ( getStub . calledWith ( "kdb.insightsEnterpriseConnections" ) ) ;
577584 assert . ok ( getStub . calledWith ( "kdb.insights" ) ) ;
578585 } ) ;
@@ -620,7 +627,7 @@ describe("core", () => {
620627
621628 assert . strictEqual (
622629 result [ insightKeys [ 0 ] ] . server ,
623- "https://alpha.insights.com" ,
630+ "https://alpha.insights.com"
624631 ) ;
625632 assert . strictEqual ( result [ insightKeys [ 0 ] ] . auth , false ) ;
626633 assert . strictEqual ( result [ insightKeys [ 1 ] ] . realm , "beta-realm" ) ;
@@ -692,7 +699,8 @@ describe("core", () => {
692699
693700 const result = coreUtils . getInsights ( ) ;
694701
695- assert . strictEqual ( result , undefined ) ;
702+ assert . ok ( typeof result === "object" ) ;
703+ assert . strictEqual ( Object . keys ( result ) . length , 0 ) ;
696704 assert . ok ( getStub . calledWith ( "kdb.insightsEnterpriseConnections" ) ) ;
697705 assert . ok ( getStub . calledWith ( "kdb.insights" ) ) ;
698706 } ) ;
@@ -720,7 +728,7 @@ describe("core", () => {
720728 assert . strictEqual ( result [ insightKeys [ 0 ] ] . alias , "Only Insight" ) ;
721729 assert . strictEqual (
722730 result [ insightKeys [ 0 ] ] . server ,
723- "https://only.insights.com" ,
731+ "https://only.insights.com"
724732 ) ;
725733 } ) ;
726734
@@ -827,7 +835,7 @@ describe("core", () => {
827835
828836 coreUtils . getInsights ( ) ;
829837
830- assert . ok ( workspaceStub . calledOnce ) ;
838+ assert . ok ( workspaceStub . calledTwice ) ;
831839 assert . ok ( workspaceStub . calledWith ( ) ) ;
832840 } ) ;
833841
@@ -868,10 +876,10 @@ describe("core", () => {
868876 assert . strictEqual ( insightKeys . length , 2 ) ;
869877
870878 const basicInsight = Object . values ( result ) . find (
871- ( i ) => i . alias === "Basic Insight" ,
879+ ( i ) => i . alias === "Basic Insight"
872880 ) ;
873881 const fullInsight = Object . values ( result ) . find (
874- ( i ) => i . alias === "Full Insight" ,
882+ ( i ) => i . alias === "Full Insight"
875883 ) ;
876884
877885 assert . ok ( basicInsight ) ;
@@ -993,9 +1001,9 @@ describe("core", () => {
9931001 updateConfigurationStub . calledWith (
9941002 "kdb.neverShowQInstallAgain" ,
9951003 true ,
996- vscode . ConfigurationTarget . Global ,
1004+ vscode . ConfigurationTarget . Global
9971005 ) ,
998- true ,
1006+ true
9991007 ) ;
10001008 } ) ;
10011009 } ) ;
0 commit comments