@@ -24,6 +24,7 @@ const options: UpdateSwaggerJsonExecutorSchema = {
2424 output : '' ,
2525 startupAssembly : '' ,
2626 swaggerDoc : '' ,
27+ skipInstall : false ,
2728} ;
2829
2930const root = '/virtual' ;
@@ -109,7 +110,7 @@ describe('Update-Swagger Executor', () => {
109110 expect ( res . success ) . toBeTruthy ( ) ;
110111 } ) ;
111112
112- it ( `doesnt install ${ SWAGGER_CLI_TOOL } if already installed` , async ( ) => {
113+ it ( `doesn't install ${ SWAGGER_CLI_TOOL } if already installed` , async ( ) => {
113114 jest . spyOn ( fs , 'existsSync' ) . mockReturnValue ( true ) ;
114115 jest . spyOn ( fs , 'readFileSync' ) . mockImplementation ( ( p ) : string => {
115116 if ( p === '1.csproj' ) {
@@ -134,4 +135,24 @@ describe('Update-Swagger Executor', () => {
134135 ) . not . toHaveBeenCalled ( ) ;
135136 expect ( res . success ) . toBeTruthy ( ) ;
136137 } ) ;
138+
139+ it ( `skips installation when skipInstall is true` , async ( ) => {
140+ jest . spyOn ( fs , 'existsSync' ) . mockReturnValue ( false ) ;
141+ jest . spyOn ( fs , 'readFileSync' ) . mockImplementation ( ( p ) : string => {
142+ if ( p === '1.csproj' ) {
143+ return mockCSProj ;
144+ }
145+ throw new Error ( 'Attempted to read unexpected file' ) ;
146+ } ) ;
147+ jest . spyOn ( devkit , 'readJsonFile' ) . mockReturnValue ( { } ) ;
148+ const res = await executor (
149+ { ...options , skipInstall : true } ,
150+ context ,
151+ dotnetClient ,
152+ ) ;
153+ expect (
154+ ( dotnetClient as jest . Mocked < DotNetClient > ) . installTool ,
155+ ) . not . toHaveBeenCalled ( ) ;
156+ expect ( res . success ) . toBeTruthy ( ) ;
157+ } ) ;
137158} ) ;
0 commit comments