@@ -1353,6 +1353,7 @@ describe("connectionManagerService", () => {
13531353
13541354 describe ( "resetScratchpad" , ( ) => {
13551355 let connMngService : ConnectionManagementService ;
1356+ let retrieveConnectedConnectionStub : sinon . SinonStub ;
13561357 let resetScratchpadStub : sinon . SinonStub ;
13571358 let kdbOutputLogStub : sinon . SinonStub ;
13581359 let showInformationMessageStub : sinon . SinonStub ;
@@ -1361,7 +1362,11 @@ describe("connectionManagerService", () => {
13611362 beforeEach ( ( ) => {
13621363 connMngService = new ConnectionManagementService ( ) ;
13631364 ext . activeConnection = insightsConn ;
1364- resetScratchpadStub = sinon . stub ( ext . activeConnection , "resetScratchpad" ) ;
1365+ resetScratchpadStub = sinon . stub ( insightsConn , "resetScratchpad" ) ;
1366+ retrieveConnectedConnectionStub = sinon . stub (
1367+ connMngService ,
1368+ "retrieveConnectedConnection" ,
1369+ ) ;
13651370 kdbOutputLogStub = sinon . stub ( coreUtils , "kdbOutputLog" ) ;
13661371 showInformationMessageStub = sinon . stub ( window , "showInformationMessage" ) ;
13671372 showErrorMessageStub = sinon . stub ( window , "showErrorMessage" ) ;
@@ -1393,12 +1398,42 @@ describe("connectionManagerService", () => {
13931398
13941399 it ( "should reset the scratchpad if the active connection is an InsightsConnection" , async ( ) => {
13951400 ext . activeConnection = insightsConn ;
1396- ext . activeConnection . insightsVersion = 1.12 ;
1401+ ext . activeConnection . insightsVersion = 1.13 ;
13971402 showInformationMessageStub . resolves ( "Yes" ) ;
13981403 await connMngService . resetScratchpad ( ) ;
13991404 sinon . assert . calledOnce ( resetScratchpadStub ) ;
14001405 } ) ;
14011406
1407+ it ( "should retrieve insights connection and procced with resetScratchpad" , async ( ) => {
1408+ insightsConn . insightsVersion = 1.13 ;
1409+ retrieveConnectedConnectionStub . returns ( insightsConn ) ;
1410+ showInformationMessageStub . resolves ( "Yes" ) ;
1411+ await connMngService . resetScratchpad ( "test" ) ;
1412+ sinon . assert . calledOnce ( retrieveConnectedConnectionStub ) ;
1413+ } ) ;
1414+
1415+ it ( "should retrieve insights connection and procced with resetScratchpad" , async ( ) => {
1416+ insightsConn . insightsVersion = 1.13 ;
1417+ retrieveConnectedConnectionStub . returns ( insightsConn ) ;
1418+ showInformationMessageStub . resolves ( "No" ) ;
1419+ await connMngService . resetScratchpad ( "test" ) ;
1420+ sinon . assert . calledWith (
1421+ kdbOutputLogStub ,
1422+ "[RESET SCRATCHPAD] The user canceled the scratchpad reset." ,
1423+ "INFO" ,
1424+ ) ;
1425+ } ) ;
1426+
1427+ it ( "should retrieve kdb connection not proceed" , async ( ) => {
1428+ retrieveConnectedConnectionStub . returns ( localConn ) ;
1429+ await connMngService . resetScratchpad ( "test" ) ;
1430+ sinon . assert . calledWith (
1431+ kdbOutputLogStub ,
1432+ "[RESET SCRATCHPAD] Please connect to an Insights connection to use this feature." ,
1433+ "ERROR" ,
1434+ ) ;
1435+ } ) ;
1436+
14021437 it ( "should log an error if insightsVersion is less than or equal to 1.11" , async ( ) => {
14031438 ext . activeConnection = insightsConn ;
14041439 ext . activeConnection . insightsVersion = 1.11 ;
0 commit comments