Skip to content

Commit a7a77f3

Browse files
committed
added initMirror scenario
1 parent 6357a1f commit a7a77f3

File tree

6 files changed

+34
-2
lines changed

6 files changed

+34
-2
lines changed

test/commands/install.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ test("uninstall should remove subdependencies", () => {
619619

620620
test("install --save should add missing deps to fbkpm and mirror (PR import scenario)", async () => {
621621
let mirrorPath = "mirror-for-offline";
622-
let fixture = "install-init-mirror";
622+
let fixture = "install-import-pr";
623623
let cwd = path.join(fixturesLoc, fixture);
624624
await fs.copy(path.join(cwd, "fbkpm.lock.before"), path.join(cwd, "fbkpm.lock"));
625625

@@ -639,14 +639,40 @@ test("install --save should add missing deps to fbkpm and mirror (PR import scen
639639

640640
let lockFileContent = await fs.readFile(path.join(config.cwd, "fbkpm.lock"));
641641
let lockFileLines = lockFileContent.split("\n").filter((line) => !!line);
642+
// TODO error here
642643
assert.equal(lockFileLines.length, 14);
643644
assert.equal(lockFileLines[4].indexOf("mime-db@"), 0);
644645
assert.equal(lockFileLines[8].indexOf("mime-types@2.0.0"), 0);
645646

646647
await fs.unlink(path.join(mirror[1].absolute));
647648
await fs.unlink(path.join(mirror[2].absolute));
648649
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";
649656

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"));
650676
});
651677
});
652678

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kpm-offline-mirror=./mirror-for-offline
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"dependencies": {
3+
"fake-fbkpm-dependency": "1.0.1",
4+
"mime-types": "2.0.0"
5+
}
6+
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"dependencies": {
3-
"fake-fbkpm-dependency": "1.0.1",
43
"mime-types": "2.0.0"
54
}
65
}

0 commit comments

Comments
 (0)