@@ -385,7 +385,7 @@ test("downgrade scenario", () => {
385
385
} ) ;
386
386
} ) ;
387
387
388
- test . only ( "install have a clean node_modules after lockfile update (branch switch scenario)" , async ( ) => {
388
+ test ( "install have a clean node_modules after lockfile update (branch switch scenario)" , async ( ) => {
389
389
// A@1 -> B@1
390
390
// B@2
391
391
@@ -398,12 +398,13 @@ test.only("install have a clean node_modules after lockfile update (branch switc
398
398
// A@1.2
399
399
// B@1.2
400
400
401
- let cwd = path . join ( fixturesLoc , "install-should-cleanup-when-package-json-changed" ) ;
401
+ let fixture = "install-should-cleanup-when-package-json-changed" ;
402
+ let cwd = path . join ( fixturesLoc , fixture ) ;
402
403
403
404
await fs . copy ( path . join ( cwd , "fbkpm.lock.before" ) , path . join ( cwd , "fbkpm.lock" ) ) ;
404
405
await fs . copy ( path . join ( cwd , "package.json.before" ) , path . join ( cwd , "package.json" ) ) ;
405
406
406
- return run ( { } , [ ] , "install-should-cleanup-when-package-json-changed" , async ( config ) => {
407
+ return run ( { } , [ ] , fixture , async ( config ) => {
407
408
assert . equal ( JSON . parse ( await fs . readFile ( path . join ( config . cwd ,
408
409
"node_modules/dep-a/package.json" ) ) ) . version , "1.0.0" ) ;
409
410
assert . equal ( JSON . parse ( await fs . readFile ( path . join ( config . cwd ,
@@ -417,7 +418,7 @@ test.only("install have a clean node_modules after lockfile update (branch switc
417
418
await fs . copy ( path . join ( cwd , "fbkpm.lock.after" ) , path . join ( cwd , "fbkpm.lock" ) ) ;
418
419
await fs . copy ( path . join ( cwd , "package.json.after" ) , path . join ( cwd , "package.json" ) ) ;
419
420
420
- return run ( { } , [ ] , "install-should-cleanup-when-package-json-changed" , async ( config ) => {
421
+ return run ( { } , [ ] , fixture , async ( config ) => {
421
422
assert . equal ( JSON . parse ( await fs . readFile ( path . join ( config . cwd ,
422
423
"node_modules/dep-a/package.json" ) ) ) . version , "1.2.0" ) ;
423
424
assert . equal ( JSON . parse ( await fs . readFile ( path . join ( config . cwd ,
@@ -429,6 +430,44 @@ test.only("install have a clean node_modules after lockfile update (branch switc
429
430
} ) ;
430
431
} ) ;
431
432
433
+
434
+ test ( "install have a clean node_modules after lockfile update (branch switch scenario 2)" , async ( ) => {
435
+ // A@1 -> B@1
436
+
437
+ // after package.json/lock file update
438
+
439
+ // A@1.2
440
+
441
+ let fixture = "install-should-cleanup-when-package-json-changed-2" ;
442
+ let cwd = path . join ( fixturesLoc , fixture ) ;
443
+
444
+ await fs . copy ( path . join ( cwd , "fbkpm.lock.before" ) , path . join ( cwd , "fbkpm.lock" ) ) ;
445
+ await fs . copy ( path . join ( cwd , "package.json.before" ) , path . join ( cwd , "package.json" ) ) ;
446
+
447
+ return run ( { } , [ ] , fixture , async ( config ) => {
448
+ assert . equal ( JSON . parse ( await fs . readFile ( path . join ( config . cwd ,
449
+ "node_modules/dep-a/package.json" ) ) ) . version , "1.0.0" ) ;
450
+ assert . equal ( JSON . parse ( await fs . readFile ( path . join ( config . cwd ,
451
+ "node_modules/dep-b/package.json" ) ) ) . version , "1.0.0" ) ;
452
+
453
+ await fs . unlink ( path . join ( config . cwd , "fbkpm.lock" ) ) ;
454
+ await fs . unlink ( path . join ( config . cwd , "package.json" ) ) ;
455
+
456
+ await fs . copy ( path . join ( cwd , "fbkpm.lock.after" ) , path . join ( cwd , "fbkpm.lock" ) ) ;
457
+ await fs . copy ( path . join ( cwd , "package.json.after" ) , path . join ( cwd , "package.json" ) ) ;
458
+
459
+ return run ( { } , [ ] , fixture , async ( config ) => {
460
+ assert . equal ( JSON . parse ( await fs . readFile ( path . join ( config . cwd ,
461
+ "node_modules/dep-a/package.json" ) ) ) . version , "1.2.0" ) ;
462
+
463
+ assert ( ! await fs . exists ( path . join ( config . cwd , "node_modules/dep-b" ) ) ) ;
464
+
465
+ await fs . unlink ( path . join ( config . cwd , "fbkpm.lock" ) ) ;
466
+ await fs . unlink ( path . join ( config . cwd , "package.json" ) ) ;
467
+ } ) ;
468
+ } ) ;
469
+ } ) ;
470
+
432
471
test ( "uninstall should remove dependency from package.json, fbkpm.lock and node_modules" , ( ) => {
433
472
let mirrorPath = "mirror-for-offline" ;
434
473
0 commit comments