@@ -619,7 +619,7 @@ test("uninstall should remove subdependencies", () => {
619
619
620
620
test ( "install --save should add missing deps to fbkpm and mirror (PR import scenario)" , async ( ) => {
621
621
let mirrorPath = "mirror-for-offline" ;
622
- let fixture = "install-init-mirror " ;
622
+ let fixture = "install-import-pr " ;
623
623
let cwd = path . join ( fixturesLoc , fixture ) ;
624
624
await fs . copy ( path . join ( cwd , "fbkpm.lock.before" ) , path . join ( cwd , "fbkpm.lock" ) ) ;
625
625
@@ -639,14 +639,40 @@ test("install --save should add missing deps to fbkpm and mirror (PR import scen
639
639
640
640
let lockFileContent = await fs . readFile ( path . join ( config . cwd , "fbkpm.lock" ) ) ;
641
641
let lockFileLines = lockFileContent . split ( "\n" ) . filter ( ( line ) => ! ! line ) ;
642
+ // TODO error here
642
643
assert . equal ( lockFileLines . length , 14 ) ;
643
644
assert . equal ( lockFileLines [ 4 ] . indexOf ( "mime-db@" ) , 0 ) ;
644
645
assert . equal ( lockFileLines [ 8 ] . indexOf ( "mime-types@2.0.0" ) , 0 ) ;
645
646
646
647
await fs . unlink ( path . join ( mirror [ 1 ] . absolute ) ) ;
647
648
await fs . unlink ( path . join ( mirror [ 2 ] . absolute ) ) ;
648
649
await fs . unlink ( path . join ( config . cwd , "fbkpm.lock" ) ) ;
650
+ } ) ;
651
+ } ) ;
652
+
653
+ test ( "install --initMirror should add init mirror deps from package.json" , async ( ) => {
654
+ let mirrorPath = "mirror-for-offline" ;
655
+ let fixture = "install-init-mirror" ;
649
656
657
+ return run ( { save : true } , [ ] , fixture , async ( config , reporter ) => {
658
+ assert . equal ( JSON . parse ( await fs . readFile ( path . join ( config . cwd ,
659
+ "node_modules/mime-types/package.json" ) ) ) . version , "2.0.0" ) ;
660
+ assert ( semver . satisfies ( JSON . parse ( await fs . readFile ( path . join ( config . cwd ,
661
+ "node_modules/mime-db/package.json" ) ) ) . version , "~1.0.1" ) ) ;
662
+
663
+ let mirror = await fs . walk ( path . join ( config . cwd , mirrorPath ) ) ;
664
+ assert . equal ( mirror . length , 2 ) ;
665
+ assert . equal ( mirror [ 0 ] . relative . indexOf ( "mime-db-1.0." ) , 0 ) ;
666
+ assert . equal ( mirror [ 1 ] . relative , "mime-types-2.0.0.tgz" ) ;
667
+
668
+ let lockFileContent = await fs . readFile ( path . join ( config . cwd , "fbkpm.lock" ) ) ;
669
+ let lockFileLines = lockFileContent . split ( "\n" ) . filter ( ( line ) => ! ! line ) ;
670
+ assert . equal ( lockFileLines . length , 10 ) ;
671
+ assert . equal ( lockFileLines [ 0 ] . indexOf ( "mime-db@" ) , 0 ) ;
672
+ assert . equal ( lockFileLines [ 4 ] . indexOf ( "mime-types@2.0.0" ) , 0 ) ;
673
+
674
+ await fs . unlink ( path . join ( config . cwd , mirrorPath ) ) ;
675
+ await fs . unlink ( path . join ( config . cwd , "fbkpm.lock" ) ) ;
650
676
} ) ;
651
677
} ) ;
652
678
0 commit comments