@@ -1680,6 +1680,7 @@ describe("serverCommand", () => {
16801680 executeCommandStub . restore ( ) ;
16811681 } ) ;
16821682 } ) ;
1683+
16831684 describe ( "enableTLS" , ( ) => {
16841685 let getServersStub : sinon . SinonStub ;
16851686 let updateServersStub : sinon . SinonStub ;
@@ -2497,6 +2498,63 @@ describe("serverCommand", () => {
24972498 showQuickPickStub . restore ( ) ;
24982499 } ) ;
24992500 } ) ;
2501+
2502+ describe ( "copyQuery" , ( ) => {
2503+ let showInfoStub : sinon . SinonStub ;
2504+
2505+ beforeEach ( ( ) => {
2506+ showInfoStub = sinon . stub ( vscode . window , "showInformationMessage" ) ;
2507+ } ) ;
2508+
2509+ afterEach ( ( ) => {
2510+ sinon . restore ( ) ;
2511+ } ) ;
2512+
2513+ it ( "should copy query to clipboard" , async ( ) => {
2514+ const queryHistory : QueryHistory = {
2515+ executorName : "test" ,
2516+ connectionName : "conn" ,
2517+ connectionType : ServerType . KDB ,
2518+ query : "select from table" ,
2519+ time : "now" ,
2520+ success : true ,
2521+ } ;
2522+
2523+ await serverCommand . copyQuery ( queryHistory ) ;
2524+ sinon . assert . calledOnceWithExactly (
2525+ showInfoStub ,
2526+ "Query copied to clipboard." ,
2527+ ) ;
2528+ } ) ;
2529+
2530+ it ( "should not copy query to clipboard if query is not string" , async ( ) => {
2531+ const dummyDsFiles = createDefaultDataSourceFile ( ) ;
2532+ const queryHistory : QueryHistory = {
2533+ executorName : "test" ,
2534+ connectionName : "conn" ,
2535+ connectionType : ServerType . KDB ,
2536+ query : dummyDsFiles ,
2537+ time : "now" ,
2538+ success : true ,
2539+ } ;
2540+ await serverCommand . copyQuery ( queryHistory ) ;
2541+ sinon . assert . notCalled ( showInfoStub ) ;
2542+ } ) ;
2543+
2544+ it ( "should not copy query to clipboard if is DS" , async ( ) => {
2545+ const queryHistory : QueryHistory = {
2546+ executorName : "test" ,
2547+ connectionName : "conn" ,
2548+ connectionType : ServerType . KDB ,
2549+ query : "select from table" ,
2550+ time : "now" ,
2551+ success : true ,
2552+ isDatasource : true ,
2553+ } ;
2554+ await serverCommand . copyQuery ( queryHistory ) ;
2555+ sinon . assert . notCalled ( showInfoStub ) ;
2556+ } ) ;
2557+ } ) ;
25002558} ) ;
25012559
25022560describe ( "walkthroughCommand" , ( ) => {
0 commit comments