@@ -58,7 +58,7 @@ describe("MockedFilesystemTests", () => {
58
58
expect ( err ) . toBeUndefined ( ) ;
59
59
} ) ;
60
60
it ( "should complain if no write permission to bundle directory" , ( ) => {
61
- // Mocks for the manifest - META-INF exists
61
+ // Mocks for the manifest - META-INF doesn't exist
62
62
jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( false ) ) ;
63
63
// Mocks for the manifest - Bundle dir writable
64
64
jest . spyOn ( fs , "accessSync" ) . mockImplementationOnce ( ( ) => { throw new Error ( "Wibble" ) ; } ) ;
@@ -170,8 +170,6 @@ describe("MockedFilesystemTests", () => {
170
170
expect ( err ) . toBeUndefined ( ) ;
171
171
} ) ;
172
172
it ( "should detect inability to create .nodejsapp directory" , ( ) => {
173
-
174
- // nodejsapps and manifest don't exist
175
173
jest . spyOn ( fs , "existsSync" ) . mockImplementation ( ( path : string ) => {
176
174
if ( path . endsWith ( "nodejsapps" ) ) {
177
175
return false ;
@@ -208,8 +206,6 @@ describe("MockedFilesystemTests", () => {
208
206
expect ( err . message ) . toContain ( "cics-deploy requires write permission to: " ) ;
209
207
} ) ;
210
208
it . skip ( "should detect unwritable nodejsapps directory" , ( ) => {
211
-
212
- // nodejsapps and manifest don't exist
213
209
jest . spyOn ( fs , "existsSync" ) . mockImplementation ( ( path : string ) => {
214
210
if ( path . endsWith ( "nodejsapps" ) ) {
215
211
return false ;
@@ -334,7 +330,6 @@ describe("MockedFilesystemTests", () => {
334
330
} ) ;
335
331
it ( "should complain if no overwrite permission for existing .zosattributes" , ( ) => {
336
332
337
- // manifest don't exist, everying else does
338
333
jest . spyOn ( fs , "existsSync" ) . mockImplementation ( ( path : string ) => {
339
334
if ( path . endsWith ( "cics.xml" ) ) {
340
335
return false ;
@@ -369,16 +364,15 @@ describe("MockedFilesystemTests", () => {
369
364
expect ( err . message ) . toContain ( ".zosattributes already exists. Specify --overwrite to replace it." ) ;
370
365
} ) ;
371
366
it ( "should complain if can't make a new META-INF directory" , ( ) => {
367
+ jest . spyOn ( fs , "accessSync" ) . mockReturnValue ( true ) ;
368
+ // manifest don't exist, everying else does
369
+ jest . spyOn ( fs , "existsSync" ) . mockImplementation ( ( path : string ) => {
370
+ if ( path . endsWith ( "META-INF" ) ) {
371
+ return false ;
372
+ }
373
+ return true ;
374
+ } ) ;
372
375
373
- // Mocks for the manifest - META-INF exists
374
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
375
- // Mocks for the manifest - META-INF is writable
376
- jest . spyOn ( fs , "accessSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
377
- // Mocks for the manifest - manifest exists
378
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( false ) ) ;
379
- // Mocks for the manifest - META-INF exists (on save() rather than prepareForSave())
380
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( false ) ) ;
381
- // Mocks for the manifest - META-INF creation)
382
376
jest . spyOn ( fs , "mkdirSync" ) . mockImplementationOnce ( ( ) => { throw new Error ( "InjectedError" ) ; } ) ;
383
377
384
378
let err : Error ;
@@ -405,7 +399,7 @@ describe("MockedFilesystemTests", () => {
405
399
return true ;
406
400
} ) ;
407
401
408
- // Mocks for the manifest - manifest write)
402
+ // Mocks for the manifest - manifest write
409
403
jest . spyOn ( fs , "writeFileSync" ) . mockImplementationOnce ( ( ) => { throw new Error ( "InjectedError" ) ; } ) ;
410
404
411
405
@@ -425,7 +419,6 @@ describe("MockedFilesystemTests", () => {
425
419
} ) ;
426
420
it ( "should complain if creating nodejsapps dir fails" , ( ) => {
427
421
jest . spyOn ( fs , "accessSync" ) . mockReturnValue ( true ) ;
428
- // manifest don't exist, everying else does
429
422
jest . spyOn ( fs , "existsSync" ) . mockImplementation ( ( path : string ) => {
430
423
if ( path . endsWith ( "nodejsapps" ) ) {
431
424
return false ;
@@ -452,7 +445,6 @@ describe("MockedFilesystemTests", () => {
452
445
} ) ;
453
446
it ( "should complain if writing .nodejsapp file fails" , ( ) => {
454
447
jest . spyOn ( fs , "accessSync" ) . mockReturnValue ( true ) ;
455
- // manifest don't exist, everying else does
456
448
jest . spyOn ( fs , "existsSync" ) . mockImplementation ( ( path : string ) => {
457
449
if ( path . endsWith ( ".nodejsapp" ) ) {
458
450
return false ;
@@ -479,32 +471,19 @@ describe("MockedFilesystemTests", () => {
479
471
expect ( err . message ) . toContain ( "InjectedError" ) ;
480
472
} ) ;
481
473
it ( "should complain if writing .profile fails" , ( ) => {
474
+ jest . spyOn ( fs , "accessSync" ) . mockReturnValue ( true ) ;
475
+ jest . spyOn ( fs , "existsSync" ) . mockImplementation ( ( path : string ) => {
476
+ if ( path . endsWith ( ".profile" ) ) {
477
+ return false ;
478
+ }
479
+ return true ;
480
+ } ) ;
482
481
483
- // Mocks for the Nodejsapp - startscript exists
484
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
485
- // Mocks for the manifest - META-INF exists
486
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
487
- // Mocks for the manifest - META-INF is writable
488
- jest . spyOn ( fs , "accessSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
489
- // Mocks for the manifest - manifest exists
490
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( false ) ) ;
491
- // Mocks for the Nodejsapp - nodejsapp dir exists
492
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
493
- // Mocks for the Nodejsapp - nodejsapp dir writable
494
- jest . spyOn ( fs , "accessSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
495
- // Mocks for the Nodejsapp - .nodejsapp file exists
496
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( false ) ) ;
497
- // Mocks for the Nodejsapp - .profile file exists
498
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( false ) ) ;
499
- // Mocks for the Nodejsapp - .zosattributes file exists
500
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( false ) ) ;
501
-
502
- // Mocks for the nodejsapp - nodejsapps dir exists (on save() rather than prepareForSave())
503
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
504
- // Mocks for the nodejsapp - write .nodejsapp file)
505
- jest . spyOn ( fs , "writeFileSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
506
- // Mocks for the nodejsapp - write .profile file)
507
- jest . spyOn ( fs , "writeFileSync" ) . mockImplementationOnce ( ( ) => { throw new Error ( "InjectedError" ) ; } ) ;
482
+ jest . spyOn ( fs , "writeFileSync" ) . mockImplementation ( ( path : string ) => {
483
+ if ( path . endsWith ( ".profile" ) ) {
484
+ throw new Error ( "InjectedError" ) ;
485
+ }
486
+ } ) ;
508
487
509
488
let err : Error ;
510
489
try {
@@ -522,34 +501,20 @@ describe("MockedFilesystemTests", () => {
522
501
expect ( err . message ) . toContain ( "InjectedError" ) ;
523
502
} ) ;
524
503
it ( "should complain if writing .zosattributes fails" , ( ) => {
504
+ jest . spyOn ( fs , "accessSync" ) . mockReturnValue ( true ) ;
505
+ jest . spyOn ( fs , "existsSync" ) . mockImplementation ( ( path : string ) => {
506
+ if ( path . endsWith ( ".zosattributes" ) ) {
507
+ return false ;
508
+ }
509
+ return true ;
510
+ } ) ;
525
511
526
- // Mocks for the Nodejsapp - startscript exists
527
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
528
- // Mocks for the manifest - META-INF exists
529
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
530
- // Mocks for the manifest - META-INF is writable
531
- jest . spyOn ( fs , "accessSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
532
- // Mocks for the manifest - manifest exists
533
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( false ) ) ;
534
- // Mocks for the Nodejsapp - nodejsapp dir exists
535
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
536
- // Mocks for the Nodejsapp - nodejsapp dir writable
537
- jest . spyOn ( fs , "accessSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
538
- // Mocks for the Nodejsapp - .nodejsapp file exists
539
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( false ) ) ;
540
- // Mocks for the Nodejsapp - .profile file exists
541
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( false ) ) ;
542
- // Mocks for the Nodejsapp - .zosattributes file exists
543
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( false ) ) ;
544
-
545
- // Mocks for the nodejsapp - nodejsapps dir exists (on save() rather than prepareForSave())
546
- jest . spyOn ( fs , "existsSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
547
- // Mocks for the nodejsapp - write .nodejsapp file)
548
- jest . spyOn ( fs , "writeFileSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
549
- // Mocks for the nodejsapp - write .profile file)
550
- jest . spyOn ( fs , "writeFileSync" ) . mockImplementationOnce ( ( ) => ( true ) ) ;
551
- // Mocks for the zosattributes - write .zosattributes file)
552
- jest . spyOn ( fs , "writeFileSync" ) . mockImplementationOnce ( ( ) => { throw new Error ( "InjectedError" ) ; } ) ;
512
+ // Mocks for the nodejsapp - write .zosattributes
513
+ jest . spyOn ( fs , "writeFileSync" ) . mockImplementation ( ( path : string ) => {
514
+ if ( path . endsWith ( ".zosattributes" ) ) {
515
+ throw new Error ( "InjectedError" ) ;
516
+ }
517
+ } ) ;
553
518
554
519
let err : Error ;
555
520
try {
0 commit comments