Skip to content

Commit ec194bf

Browse files
committed
added test that passes
1 parent 968eab6 commit ec194bf

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

test/commands/install.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ test("install --save with new dependency should be deterministic", async () => {
793793
});
794794
});
795795

796-
test.only("install --save with new dependency should be deterministic 2", async () => {
796+
test("install --save with new dependency should be deterministic 2", async () => {
797797
// mime-types@2.0.0->mime-db@1.0.1 is saved in local mirror and is deduped
798798
// install mime-db@1.0.3 should replace mime-db@1.0.1 in root
799799

@@ -845,3 +845,46 @@ test.only("install --save with new dependency should be deterministic 2", async
845845
});
846846
});
847847
});
848+
849+
850+
test("install --save should ignore cache", () => {
851+
// left-pad@1.1.0 gets installed without --save
852+
// left-pad@1.1.0 gets installed with --save
853+
// files in mirror, fbkpm.lock, package.json and node_modules should reflect that
854+
855+
let mirrorPath = "mirror-for-offline";
856+
857+
let fixture = "install-save-to-mirror-when-cached";
858+
return run({}, ["left-pad@1.1.0"], fixture, async (config) => {
859+
assert.equal(
860+
JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/left-pad/package.json"))).version,
861+
"1.1.0"
862+
);
863+
864+
return run({save: true}, ["left-pad@1.1.0"], fixture, async (config) => {
865+
assert.equal(
866+
JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/left-pad/package.json"))).version,
867+
"1.1.0"
868+
);
869+
assert.deepEqual(
870+
JSON.parse(await fs.readFile(path.join(config.cwd, "package.json"))).dependencies,
871+
{"left-pad": "1.1.0"}
872+
);
873+
874+
let lockFileWritten = await fs.readFile(path.join(config.cwd, "fbkpm.lock"));
875+
let lockFileLines = lockFileWritten.split("\n").filter((line) => !!line);
876+
assert.equal(lockFileLines[0], "left-pad@1.1.0:");
877+
assert.equal(lockFileLines.length, 4);
878+
assert.notEqual(lockFileLines[3].indexOf("resolved left-pad-1.1.0.tgz"), -1);
879+
880+
throw new Error("AA")
881+
882+
let mirror = await fs.walk(path.join(config.cwd, mirrorPath));
883+
assert.equal(mirror.length, 1);
884+
assert.equal(mirror[0].relative, "left-pad-1.1.0.tgz");
885+
await fs.unlink(path.join(config.cwd, mirrorPath));
886+
await fs.unlink(path.join(config.cwd, "package.json"));
887+
888+
});
889+
});
890+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kpm-offline-mirror=./mirror-for-offline

0 commit comments

Comments
 (0)