@@ -361,13 +361,16 @@ describe("Utils", () => {
361361 } ) ;
362362
363363 describe ( "getServers" , ( ) => {
364- let workspaceStub : sinon . SinonStub ;
365- let _getConfigurationStub : sinon . SinonStub ;
366- let getStub : sinon . SinonStub ;
364+ let workspaceStub ,
365+ _getConfigurationStub ,
366+ getStub ,
367+ updateServersStub : sinon . SinonStub ;
367368
368369 beforeEach ( ( ) => {
369370 getStub = sinon . stub ( ) ;
370- _getConfigurationStub = sinon . stub ( ) . returns ( { get : getStub } ) ;
371+ _getConfigurationStub = sinon
372+ . stub ( )
373+ . returns ( { get : getStub , update : sinon . stub ( ) } ) ;
371374 workspaceStub = sinon
372375 . stub ( vscode . workspace , "getConfiguration" )
373376 . returns ( {
@@ -403,18 +406,19 @@ describe("Utils", () => {
403406 throw new Error ( "Function not implemented." ) ;
404407 } ,
405408 } ) ;
409+ updateServersStub = sinon . stub ( coreUtils , "updateServers" ) . resolves ( ) ;
406410 } ) ;
407411
408412 afterEach ( ( ) => {
409413 sinon . restore ( ) ;
410414 } ) ;
411415
412- it ( "should return undefined when no servers are configured" , ( ) => {
413- getStub . returns ( undefined ) ;
414-
416+ it ( "should return an empty object when no servers are configured" , ( ) => {
417+ getStub . returns ( { } ) ;
415418 const result = coreUtils . getServers ( ) ;
416419
417- assert . strictEqual ( result , undefined ) ;
420+ assert . ok ( typeof result === "object" ) ;
421+ assert . strictEqual ( Object . keys ( result ) . length , 0 ) ;
418422 assert . ok ( getStub . calledWith ( "kdb.servers" ) ) ;
419423 } ) ;
420424
@@ -580,7 +584,7 @@ describe("Utils", () => {
580584
581585 coreUtils . getServers ( ) ;
582586
583- assert . ok ( workspaceStub . calledOnce ) ;
587+ assert . ok ( workspaceStub . calledTwice ) ;
584588 assert . ok ( workspaceStub . calledWith ( ) ) ;
585589 } ) ;
586590
@@ -595,13 +599,16 @@ describe("Utils", () => {
595599 } ) ;
596600
597601 describe ( "getInsights" , ( ) => {
598- let workspaceStub : sinon . SinonStub ;
599- let _getConfigurationStub : sinon . SinonStub ;
600- let getStub : sinon . SinonStub ;
602+ let workspaceStub ,
603+ _getConfigurationStub ,
604+ getStub ,
605+ updateInsightsStub : sinon . SinonStub ;
601606
602607 beforeEach ( ( ) => {
603608 getStub = sinon . stub ( ) ;
604- _getConfigurationStub = sinon . stub ( ) . returns ( { get : getStub } ) ;
609+ _getConfigurationStub = sinon
610+ . stub ( )
611+ . returns ( { get : getStub , update : sinon . stub ( ) } ) ;
605612 workspaceStub = sinon
606613 . stub ( vscode . workspace , "getConfiguration" )
607614 . returns ( {
@@ -625,18 +632,9 @@ describe("Utils", () => {
625632 | undefined {
626633 throw new Error ( "Function not implemented." ) ;
627634 } ,
628- update : function (
629- _section : string ,
630- _value : any ,
631- _configurationTarget ?:
632- | vscode . ConfigurationTarget
633- | boolean
634- | null ,
635- _overrideInLanguage ?: boolean ,
636- ) : Thenable < void > {
637- throw new Error ( "Function not implemented." ) ;
638- } ,
635+ update : sinon . stub ( ) ,
639636 } ) ;
637+ updateInsightsStub = sinon . stub ( coreUtils , "updateInsights" ) . resolves ( ) ;
640638 } ) ;
641639
642640 afterEach ( ( ) => {
@@ -651,7 +649,8 @@ describe("Utils", () => {
651649
652650 const result = coreUtils . getInsights ( ) ;
653651
654- assert . strictEqual ( result , undefined ) ;
652+ assert . ok ( typeof result === "object" ) ;
653+ assert . strictEqual ( Object . keys ( result ) . length , 0 ) ;
655654 assert . ok ( getStub . calledWith ( "kdb.insightsEnterpriseConnections" ) ) ;
656655 assert . ok ( getStub . calledWith ( "kdb.insights" ) ) ;
657656 } ) ;
@@ -767,13 +766,14 @@ describe("Utils", () => {
767766 assert . ok ( getStub . calledWith ( "kdb.insights" ) ) ;
768767 } ) ;
769768
770- it ( "should return undefined when both sources are empty" , ( ) => {
769+ it ( "should return empty object when both sources are empty" , ( ) => {
771770 getStub . withArgs ( "kdb.insightsEnterpriseConnections" ) . returns ( { } ) ;
772771 getStub . withArgs ( "kdb.insights" ) . returns ( { } ) ;
773772
774773 const result = coreUtils . getInsights ( ) ;
775774
776- assert . strictEqual ( result , undefined ) ;
775+ assert . ok ( typeof result === "object" ) ;
776+ assert . strictEqual ( Object . keys ( result ) . length , 0 ) ;
777777 assert . ok ( getStub . calledWith ( "kdb.insightsEnterpriseConnections" ) ) ;
778778 assert . ok ( getStub . calledWith ( "kdb.insights" ) ) ;
779779 } ) ;
@@ -913,7 +913,7 @@ describe("Utils", () => {
913913
914914 coreUtils . getInsights ( ) ;
915915
916- assert . ok ( workspaceStub . calledOnce ) ;
916+ assert . ok ( workspaceStub . calledTwice ) ;
917917 assert . ok ( workspaceStub . calledWith ( ) ) ;
918918 } ) ;
919919
0 commit comments