Skip to content

Commit 420ffe0

Browse files
Added additional file tests
1 parent d8e2f3c commit 420ffe0

1 file changed

Lines changed: 56 additions & 1 deletion

File tree

test/specs/files.spec.js

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,42 @@ const { chaiExec, expect } = require("../utils/chai");
55

66
describe.skip("bump [files...]", () => {
77

8+
it("should update the package.json and package-lock.json by default", () => {
9+
files.create("package.json", { version: "1.2.3" });
10+
files.create("package-lock.json", { version: "1.2.3" });
11+
12+
let bump = chaiExec("major");
13+
14+
expect(bump).to.have.stderr("");
15+
expect(bump).to.have.exitCode(0);
16+
17+
bump.should.have.stdout(
18+
`${check} Updated package.json to 2.0.0\n` +
19+
`${check} Updated package-lock.json to 2.0.0\n`
20+
);
21+
22+
expect(files.json("package.json").version).to.equal("2.0.0");
23+
expect(files.json("package-lock.json").version).to.equal("2.0.0");
24+
});
25+
26+
it("should not update package.json if package-lock.json is explicitly specified", () => {
27+
files.create("package.json", { version: "1.2.3" });
28+
files.create("package-lock.json", { version: "1.2.3" });
29+
30+
let bump = chaiExec("major");
31+
32+
expect(bump).to.have.stderr("");
33+
expect(bump).to.have.exitCode(0);
34+
35+
bump.should.have.stdout(
36+
`${check} Updated package.json to 2.0.0\n` +
37+
`${check} Updated package-lock.json to 2.0.0\n`
38+
);
39+
40+
expect(files.json("package.json").version).to.equal("2.0.0");
41+
expect(files.json("package-lock.json").version).to.equal("2.0.0");
42+
});
43+
844
it("should replace the version number in non-manifest files", () => {
945
files.create("package.json", { version: "1.2.3" });
1046
files.create("LICENSE", fixtures.license);
@@ -14,7 +50,7 @@ describe.skip("bump [files...]", () => {
1450
files.create("subdir/deep/script1.js", fixtures.script1);
1551
files.create("subdir/deep/script2.js", fixtures.script2);
1652

17-
let bump = chaiExec("major LICENSE README.* *.js");
53+
let bump = chaiExec("major LICENSE README.* **/*.js");
1854

1955
expect(bump).to.have.stderr("");
2056
expect(bump).to.have.exitCode(0);
@@ -33,8 +69,27 @@ describe.skip("bump [files...]", () => {
3369
expect(files.text("script1.js")).to.match(/let version = "2.0.0";/);
3470
});
3571

72+
it("should not replace other version fields in manifest files", () => {
73+
files.create("package.json", { version: "1.2.3", notTheVersion: "1.2.3" });
74+
files.create("package-lock.json", { version: "1.2.3", notTheVersion: "1.2.3" });
75+
76+
let bump = chaiExec("major");
77+
78+
expect(bump).to.have.stderr("");
79+
expect(bump).to.have.exitCode(0);
80+
81+
bump.should.have.stdout(
82+
`${check} Updated package.json to 2.0.0\n` +
83+
`${check} Updated package-lock.json to 2.0.0\n`
84+
);
85+
86+
expect(files.text("README.md")).to.match(/version 5.6.7 and v8.9.10 should not be changed/);
87+
expect(files.text("script2.js")).to.match(/version 3.2.1 and v8.9.10 don't match the old version number/);
88+
});
89+
3690
it("should not replace other version numbers in non-manifest files", () => {
3791
files.create("package.json", { version: "1.2.3" });
92+
files.create("package-lock.json", { version: "1.2.3" });
3893
files.create("LICENSE", fixtures.license);
3994
files.create("README.md", fixtures.readme);
4095
files.create("script1.js", fixtures.script1);

0 commit comments

Comments
 (0)