@@ -155,32 +155,32 @@ describe('AppBuilder Walkthrough', function () {
155155 } )
156156
157157 describe ( 'Create project' , function ( ) {
158- let sandbox : sinon . SinonSandbox
158+ const workspaceUri = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri
159+ const prevInfo = 'random text'
160+ assert . ok ( workspaceUri )
159161
160- beforeEach ( function ( ) {
161- sandbox = sinon . createSandbox ( )
162+ before ( async function ( ) {
163+ await fs . delete ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , { force : true } )
162164 } )
163165
164- afterEach ( function ( ) {
165- sandbox . restore ( )
166+ beforeEach ( async function ( ) {
167+ await fs . writeFile ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , prevInfo )
168+ } )
169+
170+ afterEach ( async function ( ) {
171+ await fs . delete ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , { force : true } )
166172 } )
167173
168174 it ( 'open existing template' , async function ( ) {
169- // Given
170- const workspaceUri = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri
171- assert . ok ( workspaceUri )
175+ // Given no template exist
176+ await fs . delete ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , { force : true } )
172177 // When
173178 await genWalkthroughProject ( 'CustomTemplate' , workspaceUri , undefined )
174- // Then
179+ // Then nothing should be created
175180 assert . equal ( await fs . exists ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) ) , false )
176181 } )
177182
178183 it ( 'build an app with appcomposer overwrite' , async function ( ) {
179- // Given
180- const workspaceUri = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri
181- assert . ok ( workspaceUri )
182- await fs . writeFile ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , 'random text' )
183- const prevInfo = await fs . readFileText ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) )
184184 getTestWindow ( ) . onDidShowMessage ( ( message ) => {
185185 message . selectItem ( 'Yes' )
186186 } )
@@ -192,10 +192,6 @@ describe('AppBuilder Walkthrough', function () {
192192
193193 it ( 'build an app with appcomposer no overwrite' , async function ( ) {
194194 // Given
195- const workspaceUri = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri
196- assert . ok ( workspaceUri )
197- await fs . writeFile ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , 'random text' )
198- const prevInfo = await fs . readFileText ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) )
199195 getTestWindow ( ) . onDidShowMessage ( ( message ) => {
200196 message . selectItem ( 'No' )
201197 } )
@@ -213,11 +209,6 @@ describe('AppBuilder Walkthrough', function () {
213209
214210 it ( 'download serverlessland proj' , async function ( ) {
215211 // Given
216- const workspaceUri = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri
217- assert . ok ( workspaceUri )
218- // makesure template exist
219- await fs . writeFile ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , '' )
220- const prevInfo = await fs . readFileText ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) )
221212 // select overwrite
222213 getTestWindow ( ) . onDidShowMessage ( ( message ) => {
223214 message . selectItem ( 'Yes' )
@@ -231,11 +222,6 @@ describe('AppBuilder Walkthrough', function () {
231222
232223 it ( 'download serverlessland proj no overwrite' , async function ( ) {
233224 // Given existing template.yaml
234- const workspaceUri = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri
235- assert . ok ( workspaceUri )
236- // makesure template exist
237- await fs . writeFile ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) , '' )
238- const prevInfo = await fs . readFileText ( vscode . Uri . joinPath ( workspaceUri , 'template.yaml' ) )
239225 // select do not overwrite
240226 getTestWindow ( ) . onDidShowMessage ( ( message ) => {
241227 message . selectItem ( 'No' )
0 commit comments