@@ -4,7 +4,7 @@ const datauri = require("datauri"); // eslint-disable-line @typescript-eslint/no
44import * as fsextra from "fs-extra" ;
55import { expect } from "chai" ;
66import * as _ from "lodash" ;
7- import { CodeSnippet } from "../src/code-snippet" ;
7+ import { CodeSnippet } from "../src/code-snippet" ;
88import { AppLog } from "../src/app-log" ;
99import { AppEvents } from '../src/app-events' ;
1010import { IMethod , IPromiseCallbacks , IRpc } from "@sap-devx/webview-rpc/out.ext/rpc-common" ;
@@ -31,30 +31,30 @@ describe('codeSnippet unit test', () => {
3131 }
3232 }
3333 class TestRpc implements IRpc {
34- public timeout : number ;
34+ public timeout : number ;
3535 public promiseCallbacks : Map < number , IPromiseCallbacks > ;
3636 public methods : Map < string , IMethod > ;
3737 public sendRequest ( ) : void {
3838 return ;
39- }
39+ }
4040 public sendResponse ( ) : void {
4141 return ;
42- }
42+ }
4343 public setResponseTimeout ( ) : void {
4444 return ;
4545 }
4646 public registerMethod ( ) : void {
4747 return ;
48- }
48+ }
4949 public unregisterMethod ( ) : void {
5050 return ;
51- }
51+ }
5252 public listLocalMethods ( ) : string [ ] {
5353 return [ ] ;
5454 }
5555 public handleResponse ( ) : void {
5656 return ;
57- }
57+ }
5858 public listRemoteMethods ( ) : Promise < string [ ] > {
5959 return Promise . resolve ( [ ] ) ;
6060 }
@@ -68,31 +68,31 @@ describe('codeSnippet unit test', () => {
6868 class TestOutputChannel implements AppLog {
6969 public log ( ) : void {
7070 return ;
71- }
71+ }
7272 public writeln ( ) : void {
7373 return ;
74- }
74+ }
7575 public create ( ) : void {
7676 return ;
77- }
77+ }
7878 public force ( ) : void {
7979 return ;
80- }
80+ }
8181 public conflict ( ) : void {
8282 return ;
83- }
83+ }
8484 public identical ( ) : void {
8585 return ;
86- }
86+ }
8787 public skip ( ) : void {
8888 return ;
89- }
89+ }
9090 public showOutput ( ) : boolean {
9191 return false ;
92- }
92+ }
9393 }
9494
95- const testLogger = { debug : ( ) => "" , error : ( ) => "" , fatal : ( ) => "" , warn : ( ) => "" , info : ( ) => "" , trace : ( ) => "" , getChildLogger : ( ) => ( { } as IChildLogger ) } ;
95+ const testLogger = { debug : ( ) => "" , error : ( ) => "" , fatal : ( ) => "" , warn : ( ) => "" , info : ( ) => "" , trace : ( ) => "" , getChildLogger : ( ) => ( { } as IChildLogger ) } ;
9696
9797 const snippet : any = {
9898 getMessages ( ) {
@@ -109,7 +109,7 @@ describe('codeSnippet unit test', () => {
109109 const rpc = new TestRpc ( ) ;
110110 const outputChannel = new TestOutputChannel ( ) ;
111111 const appEvents = new TestEvents ( ) ;
112- const uiOptions = { messages : { title : "snippet title" } , snippet : snippet } ;
112+ const uiOptions = { messages : { title : "snippet title" } , snippet : snippet } ;
113113 const codeSnippet : CodeSnippet = new CodeSnippet ( rpc , appEvents , outputChannel , testLogger , uiOptions ) ;
114114
115115 before ( ( ) => {
@@ -157,13 +157,13 @@ describe('codeSnippet unit test', () => {
157157 expect ( state . stateError ) . to . be . true ;
158158 } ) ;
159159 } ) ;
160-
160+
161161 describe ( "receiveIsWebviewReady" , ( ) => {
162162 it ( "flow is successfull" , async ( ) => {
163163 rpcMock . expects ( "invoke" ) . withArgs ( "showPrompt" ) . resolves (
164- { actionName : "actionName" } ,
165- { actionTemplate : "OData action" } ,
166- { actionType : "Create entity" } ) ;
164+ { actionName : "actionName" } ,
165+ { actionTemplate : "OData action" } ,
166+ { actionType : "Create entity" } ) ;
167167 appEventsMock . expects ( "doApply" ) ;
168168 await codeSnippet [ "receiveIsWebviewReady" ] ( ) ;
169169 } ) ;
@@ -217,9 +217,9 @@ describe('codeSnippet unit test', () => {
217217 describe ( "answersUtils" , ( ) => {
218218 it ( "setDefaults" , ( ) => {
219219 const questions = [
220- { name : "q1" , default : "a" } ,
221- { name : "q2" , default : ( ) => { return "b" ; } } ,
222- { name : "q3" }
220+ { name : "q1" , default : "a" } ,
221+ { name : "q2" , default : ( ) => { return "b" ; } } ,
222+ { name : "q3" }
223223 ] ;
224224 const answers = {
225225 q1 : "x" ,
@@ -252,9 +252,9 @@ describe('codeSnippet unit test', () => {
252252 } ;
253253 } ;
254254 const codeSnippetInstance : CodeSnippet = new CodeSnippet ( rpc , appEvents , outputChannel , testLogger , { } ) ;
255- const questions = [ { name : "q1" } ] ;
255+ const questions = [ { name : "q1" } ] ;
256256 const response = await codeSnippetInstance . showPrompt ( questions ) ;
257- expect ( response . firstName ) . to . equal ( firstName ) ;
257+ expect ( response . firstName ) . to . equal ( firstName ) ;
258258 } ) ;
259259
260260 } ) ;
@@ -288,7 +288,7 @@ describe('codeSnippet unit test', () => {
288288 } ;
289289 const questions = [
290290 {
291- name :"q1" ,
291+ name : "q1" ,
292292 guiType : "questionType"
293293 }
294294 ] ;
@@ -311,25 +311,29 @@ describe('codeSnippet unit test', () => {
311311 } ;
312312 const codeSnippetInstance : CodeSnippet = new CodeSnippet ( rpc , appEvents , outputChannel , testLogger , { } ) ;
313313 codeSnippetInstance . registerCustomQuestionEventHandler ( "questionType" , "testEvent" , testEventFunction ) ;
314- codeSnippetInstance [ "currentQuestions" ] = [ { name :"question1" , guiType : "questionType" } ] ;
314+ codeSnippetInstance [ "currentQuestions" ] = [ { name : "question1" , guiType : "questionType" } ] ;
315315 const response = await codeSnippetInstance [ "evaluateMethod" ] ( null , "question1" , "testEvent" ) ;
316316 expect ( response ) . to . be . true ;
317317 } ) ;
318318
319319 it ( "question method is called" , async ( ) => {
320320 const codeSnippetInstance : CodeSnippet = new CodeSnippet ( rpc , appEvents , outputChannel , testLogger , { } ) ;
321- codeSnippetInstance [ "currentQuestions" ] = [ { name :"question1" , method1 :( ) => {
322- return true ;
323- } } ] ;
321+ codeSnippetInstance [ "currentQuestions" ] = [ {
322+ name : "question1" , method1 : ( ) => {
323+ return true ;
324+ }
325+ } ] ;
324326 const response = await codeSnippetInstance [ "evaluateMethod" ] ( null , "question1" , "method1" ) ;
325327 expect ( response ) . to . be . true ;
326328 } ) ;
327329
328330 it ( "no relevant question" , async ( ) => {
329331 const codeSnippetInstance : CodeSnippet = new CodeSnippet ( rpc , appEvents , outputChannel , testLogger , { } ) ;
330- codeSnippetInstance [ "currentQuestions" ] = [ { name :"question1" , method1 :( ) => {
331- return true ;
332- } } ] ;
332+ codeSnippetInstance [ "currentQuestions" ] = [ {
333+ name : "question1" , method1 : ( ) => {
334+ return true ;
335+ }
336+ } ] ;
333337 const response = await codeSnippetInstance [ "evaluateMethod" ] ( null , "question2" , "method2" ) ;
334338 expect ( response ) . to . be . undefined ;
335339 } ) ;
@@ -344,12 +348,14 @@ describe('codeSnippet unit test', () => {
344348 const codeSnippetInstance : CodeSnippet = new CodeSnippet ( rpc , appEvents , outputChannel , testLogger , { } ) ;
345349 codeSnippetInstance [ "gen" ] = Object . create ( { } ) ;
346350 codeSnippetInstance [ "gen" ] . options = { } ;
347- codeSnippetInstance [ "currentQuestions" ] = [ { name :"question1" , method1 :( ) => {
348- throw new Error ( "Error" ) ;
349- } } ] ;
351+ codeSnippetInstance [ "currentQuestions" ] = [ {
352+ name : "question1" , method1 : ( ) => {
353+ throw new Error ( "Error" ) ;
354+ }
355+ } ] ;
350356 try {
351357 await codeSnippetInstance [ "evaluateMethod" ] ( null , "question1" , "method1" ) ;
352- } catch ( e ) {
358+ } catch ( e ) {
353359 expect ( e . toString ( ) ) . to . contain ( "method1" ) ;
354360 }
355361 } ) ;
@@ -361,7 +367,7 @@ describe('codeSnippet unit test', () => {
361367 let codeSnippetInstance : CodeSnippet ;
362368
363369 beforeEach ( ( ) => {
364- codeSnippetInstance = new CodeSnippet ( rpc , appEvents , outputChannel , testLogger , { messages : { title : title } } ) ;
370+ codeSnippetInstance = new CodeSnippet ( rpc , appEvents , outputChannel , testLogger , { messages : { title : title } } ) ;
365371 codeSnippetInstanceMock = sandbox . mock ( codeSnippetInstance ) ;
366372 } ) ;
367373
@@ -396,10 +402,10 @@ describe('codeSnippet unit test', () => {
396402 onFailureSpy . restore ( ) ;
397403 } ) ;
398404 } ) ;
399-
405+
400406 describe ( "createCodeSnippetWorkspaceEdit" , ( ) => {
401407 it ( "snippet has getWorkspaceEdit ---> call getWorkspaceEdit" , async ( ) => {
402- const myCodeSnippet = new CodeSnippet ( rpc , appEvents , outputChannel , testLogger , { snippet : snippet } ) ;
408+ const myCodeSnippet = new CodeSnippet ( rpc , appEvents , outputChannel , testLogger , { snippet : snippet } ) ;
403409 const we = await myCodeSnippet [ "createCodeSnippetWorkspaceEdit" ] ( { } ) ;
404410 expect ( we ) . to . be . equal ( "getWorkspaceEdit" ) ;
405411 } ) ;
@@ -413,7 +419,7 @@ describe('codeSnippet unit test', () => {
413419
414420 describe ( "createCodeSnippetQuestions" , ( ) => {
415421 it ( "snippet has getQuestions ---> call getQuestions" , async ( ) => {
416- const myCodeSnippet = new CodeSnippet ( rpc , appEvents , outputChannel , testLogger , { snippet : snippet } ) ;
422+ const myCodeSnippet = new CodeSnippet ( rpc , appEvents , outputChannel , testLogger , { snippet : snippet } ) ;
417423 const we = await myCodeSnippet [ "createCodeSnippetQuestions" ] ( ) ;
418424 expect ( we ) . to . be . equal ( "createCodeSnippetQuestions" ) ;
419425 } ) ;
@@ -429,7 +435,7 @@ describe('codeSnippet unit test', () => {
429435 codeSnippetInstance . registerCustomQuestionEventHandler ( "questionType" , "testEvent1" , testEventFunction ) ;
430436 expect ( codeSnippetInstance [ "customQuestionEventHandlers" ] . size ) . to . be . equal ( 1 ) ;
431437
432- codeSnippetInstance . registerCustomQuestionEventHandler ( "questionType" , "testEvent2" , testEventFunction ) ;
438+ codeSnippetInstance . registerCustomQuestionEventHandler ( "questionType" , "testEvent2" , testEventFunction ) ;
433439 expect ( codeSnippetInstance [ "customQuestionEventHandlers" ] . size ) . to . be . equal ( 1 ) ;
434440
435441 } ) ;
0 commit comments