@@ -11,13 +11,16 @@ import { ApiAction, Command, MessageType, WebviewContext } from '../../../stepFu
1111import * as vscode from 'vscode'
1212
1313describe ( 'WorkflowStudioApiHandler' , function ( ) {
14- it ( 'should handle request and response for success' , async function ( ) {
14+ let postMessageStub : sinon . SinonStub
15+ let apiHandler : WorkflowStudioApiHandler
16+
17+ beforeEach ( ( ) => {
1518 const panel = vscode . window . createWebviewPanel ( 'WorkflowStudioMock' , 'WorkflowStudioMockTitle' , {
1619 viewColumn : vscode . ViewColumn . Active ,
1720 preserveFocus : true ,
1821 } )
1922
20- const postMessageStub = sinon . stub ( panel . webview , 'postMessage' )
23+ postMessageStub = sinon . stub ( panel . webview , 'postMessage' )
2124
2225 const context : WebviewContext = {
2326 defaultTemplateName : '' ,
@@ -31,8 +34,10 @@ describe('WorkflowStudioApiHandler', function () {
3134 fileId : '' ,
3235 }
3336
34- const apiHandler = new WorkflowStudioApiHandler ( 'us-east-1' , context )
37+ apiHandler = new WorkflowStudioApiHandler ( 'us-east-1' , context )
38+ } )
3539
40+ it ( 'should handle request and response for success' , async function ( ) {
3641 sinon . stub ( apiHandler , 'testState' ) . returns (
3742 Promise . resolve ( {
3843 output : 'Test state output' ,
@@ -65,27 +70,6 @@ describe('WorkflowStudioApiHandler', function () {
6570 } )
6671
6772 it ( 'should handle request and response for error' , async function ( ) {
68- const panel = vscode . window . createWebviewPanel ( 'WorkflowStudioMock' , 'WorkflowStudioMockTitle' , {
69- viewColumn : vscode . ViewColumn . Active ,
70- preserveFocus : true ,
71- } )
72-
73- const postMessageStub = sinon . stub ( panel . webview , 'postMessage' )
74-
75- const context : WebviewContext = {
76- defaultTemplateName : '' ,
77- defaultTemplatePath : '' ,
78- disposables : [ ] ,
79- panel : panel ,
80- textDocument : new MockDocument ( '' , 'foo' , async ( ) => true ) ,
81- workSpacePath : '' ,
82- fileStates : { } ,
83- loaderNotification : undefined ,
84- fileId : '' ,
85- }
86-
87- const apiHandler = new WorkflowStudioApiHandler ( 'us-east-1' , context )
88-
8973 sinon . stub ( apiHandler , 'testState' ) . returns ( Promise . reject ( new Error ( 'Error testing state' ) ) )
9074
9175 await apiHandler . performApiCall ( {
0 commit comments