@@ -210,97 +210,4 @@ describe('authutil tests', () => {
210
210
`@otherscope:registry=MMM${ os . EOL } //registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${ os . EOL } @myscope:registry=https://registry.npmjs.org/${ os . EOL } always-auth=true`
211
211
) ;
212
212
} ) ;
213
-
214
- describe ( 'getPackageManagerWorkingDir' , ( ) => {
215
- let existsSpy : jest . SpyInstance ;
216
- let lstatSpy : jest . SpyInstance ;
217
-
218
- beforeEach ( ( ) => {
219
- existsSpy = jest . spyOn ( fs , 'existsSync' ) ;
220
- existsSpy . mockImplementation ( ( ) => true ) ;
221
-
222
- lstatSpy = jest . spyOn ( fs , 'lstatSync' ) ;
223
- lstatSpy . mockImplementation ( arg => ( {
224
- isDirectory : ( ) => true
225
- } ) ) ;
226
- } ) ;
227
-
228
- afterEach ( ( ) => {
229
- existsSpy . mockRestore ( ) ;
230
- lstatSpy . mockRestore ( ) ;
231
- } ) ;
232
-
233
- it ( 'getPackageManagerWorkingDir should return null for not yarn' , async ( ) => {
234
- process . env [ 'INPUT_CACHE' ] = 'some' ;
235
- delete process . env [ 'INPUT_CACHE-DEPENDENCY-PATH' ] ;
236
- const dir = cacheUtils . getPackageManagerWorkingDir ( ) ;
237
- expect ( dir ) . toBeNull ( ) ;
238
- } ) ;
239
-
240
- it ( 'getPackageManagerWorkingDir should return null for not yarn with cache-dependency-path' , async ( ) => {
241
- process . env [ 'INPUT_CACHE' ] = 'some' ;
242
- process . env [ 'INPUT_CACHE-DEPENDENCY-PATH' ] = '/foo/bar' ;
243
- const dir = cacheUtils . getPackageManagerWorkingDir ( ) ;
244
- expect ( dir ) . toBeNull ( ) ;
245
- } ) ;
246
-
247
- it ( 'getPackageManagerWorkingDir should return null for yarn but without cache-dependency-path' , async ( ) => {
248
- process . env [ 'INPUT_CACHE' ] = 'yarn' ;
249
- delete process . env [ 'INPUT_CACHE-DEPENDENCY-PATH' ] ;
250
- const dir = cacheUtils . getPackageManagerWorkingDir ( ) ;
251
- expect ( dir ) . toBeNull ( ) ;
252
- } ) ;
253
-
254
- it ( 'getPackageManagerWorkingDir should return null for yarn with cache-dependency-path for not-existing directory' , async ( ) => {
255
- process . env [ 'INPUT_CACHE' ] = 'yarn' ;
256
- const cachePath = '/foo/bar' ;
257
- process . env [ 'INPUT_CACHE-DEPENDENCY-PATH' ] = cachePath ;
258
- lstatSpy . mockImplementation ( arg => ( {
259
- isDirectory : ( ) => false
260
- } ) ) ;
261
- const dir = cacheUtils . getPackageManagerWorkingDir ( ) ;
262
- expect ( dir ) . toBeNull ( ) ;
263
- } ) ;
264
-
265
- it ( 'getPackageManagerWorkingDir should return path for yarn with cache-dependency-path' , async ( ) => {
266
- process . env [ 'INPUT_CACHE' ] = 'yarn' ;
267
- const cachePath = '/foo/bar' ;
268
- process . env [ 'INPUT_CACHE-DEPENDENCY-PATH' ] = cachePath ;
269
- const dir = cacheUtils . getPackageManagerWorkingDir ( ) ;
270
- expect ( dir ) . toEqual ( path . dirname ( cachePath ) ) ;
271
- } ) ;
272
-
273
- it ( 'getCommandOutput(getPackageManagerVersion) should be called from with getPackageManagerWorkingDir result' , async ( ) => {
274
- process . env [ 'INPUT_CACHE' ] = 'yarn' ;
275
- const cachePath = '/foo/bar' ;
276
- process . env [ 'INPUT_CACHE-DEPENDENCY-PATH' ] = cachePath ;
277
- const getCommandOutputSpy = jest
278
- . spyOn ( cacheUtils , 'getCommandOutput' )
279
- . mockReturnValue ( Promise . resolve ( 'baz' ) ) ;
280
-
281
- const version = await cacheUtils . getPackageManagerVersion ( 'foo' , 'bar' ) ;
282
- expect ( getCommandOutputSpy ) . toHaveBeenCalledWith (
283
- `foo bar` ,
284
- path . dirname ( cachePath )
285
- ) ;
286
- } ) ;
287
-
288
- it ( 'getCommandOutput(getCacheDirectoryPath) should be called from with getPackageManagerWorkingDir result' , async ( ) => {
289
- process . env [ 'INPUT_CACHE' ] = 'yarn' ;
290
- const cachePath = '/foo/bar' ;
291
- process . env [ 'INPUT_CACHE-DEPENDENCY-PATH' ] = cachePath ;
292
- const getCommandOutputSpy = jest
293
- . spyOn ( cacheUtils , 'getCommandOutput' )
294
- . mockReturnValue ( Promise . resolve ( 'baz' ) ) ;
295
-
296
- const version = await cacheUtils . getCacheDirectoryPath (
297
- { lockFilePatterns : [ ] , getCacheFolderCommand : 'quz' } ,
298
- ''
299
- ) ;
300
- expect ( getCommandOutputSpy ) . toHaveBeenCalledWith (
301
- `quz` ,
302
- path . dirname ( cachePath )
303
- ) ;
304
- } ) ;
305
- } ) ;
306
213
} ) ;
0 commit comments