Skip to content

Commit 59dae4f

Browse files
Updated tests for v5.0
1 parent 277d388 commit 59dae4f

6 files changed

Lines changed: 162 additions & 264 deletions

File tree

test/specs/minor.spec.js

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,12 @@
33
const { check, files, bump } = require("../utils");
44
const { expect } = require("chai");
55

6-
describe.skip("bump --minor", () => {
7-
it("should not increment a non-existent version number", () => {
8-
files.create("package.json", {});
9-
files.create("bower.json", { name: "my-app" });
10-
11-
let cli = bump("--minor");
12-
13-
expect(cli).to.have.stderr("");
14-
expect(cli).to.have.stdout("");
15-
expect(cli).to.have.exitCode(0);
16-
17-
expect(files.json("package.json")).to.deep.equal({});
18-
expect(files.json("bower.json")).to.deep.equal({ name: "my-app" });
19-
});
20-
21-
it("should treat empty version numbers as 0.0.0", () => {
22-
files.create("package.json", { version: "" });
23-
files.create("bower.json", { version: null });
24-
files.create("component.json", { version: 0 });
25-
26-
let cli = bump("--minor");
27-
28-
expect(cli).to.have.stderr("");
29-
expect(cli).to.have.exitCode(0);
30-
31-
expect(cli).to.have.stdout(
32-
`${check} Updated package.json to 0.1.0\n` +
33-
`${check} Updated bower.json to 0.1.0\n` +
34-
`${check} Updated component.json to 0.1.0\n`
35-
);
36-
37-
expect(files.json("package.json")).to.deep.equal({ version: "0.1.0" });
38-
expect(files.json("bower.json")).to.deep.equal({ version: "0.1.0" });
39-
expect(files.json("component.json")).to.deep.equal({ version: "0.1.0" });
40-
});
6+
describe("bump minor", () => {
417

428
it("should increment an all-zero version number", () => {
439
files.create("package.json", { version: "0.0.0" });
4410

45-
let cli = bump("--minor");
11+
let cli = bump("minor");
4612

4713
expect(cli).to.have.stderr("");
4814
expect(cli).to.have.exitCode(0);
@@ -57,7 +23,7 @@ describe.skip("bump --minor", () => {
5723
it("should reset the patch", () => {
5824
files.create("package.json", { version: "1.2.3" });
5925

60-
let cli = bump("--minor");
26+
let cli = bump("minor");
6127

6228
expect(cli).to.have.stderr("");
6329
expect(cli).to.have.exitCode(0);
@@ -72,7 +38,7 @@ describe.skip("bump --minor", () => {
7238
it("should reset the prerelease version", () => {
7339
files.create("package.json", { version: "1.2.3-beta.4" });
7440

75-
let cli = bump("--minor");
41+
let cli = bump("minor");
7642

7743
expect(cli).to.have.stderr("");
7844
expect(cli).to.have.exitCode(0);
@@ -87,7 +53,7 @@ describe.skip("bump --minor", () => {
8753
it("should not be affected by the --preid flag", () => {
8854
files.create("package.json", { version: "1.2.3-beta.4" });
8955

90-
let cli = bump("--minor --preid alpha");
56+
let cli = bump("minor --preid alpha");
9157

9258
expect(cli).to.have.stderr("");
9359
expect(cli).to.have.exitCode(0);
@@ -98,4 +64,21 @@ describe.skip("bump --minor", () => {
9864

9965
expect(files.json("package.json")).to.deep.equal({ version: "1.3.0" });
10066
});
67+
68+
it("should error if there is no existing version number", () => {
69+
files.create("package.json", { name: "my-app" });
70+
files.create("bower.json", { version: "" });
71+
files.create("component.json", { version: 0 });
72+
73+
let cli = bump("minor *.json");
74+
75+
expect(cli).to.have.stdout("");
76+
expect(cli).to.have.stderr("Unable to determine the current version number. Checked bower.json, component.json, package.json.\n");
77+
expect(cli).to.have.exitCode(1);
78+
79+
expect(files.json("package.json")).to.deep.equal({ name: "my-app" });
80+
expect(files.json("bower.json")).to.deep.equal({ version: "" });
81+
expect(files.json("component.json")).to.deep.equal({ version: 0 });
82+
});
83+
10184
});

test/specs/patch.spec.js

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,12 @@
33
const { check, files, bump } = require("../utils");
44
const { expect } = require("chai");
55

6-
describe.skip("bump --patch", () => {
7-
it("should not increment a non-existent version number", () => {
8-
files.create("package.json", {});
9-
files.create("bower.json", { name: "my-app" });
10-
11-
let cli = bump("--patch");
12-
13-
expect(cli).to.have.stderr("");
14-
expect(cli).to.have.stdout("");
15-
expect(cli).to.have.exitCode(0);
16-
17-
expect(files.json("package.json")).to.deep.equal({});
18-
expect(files.json("bower.json")).to.deep.equal({ name: "my-app" });
19-
});
20-
21-
it("should treat empty version numbers as 0.0.0", () => {
22-
files.create("package.json", { version: "" });
23-
files.create("bower.json", { version: null });
24-
files.create("component.json", { version: 0 });
25-
26-
let cli = bump("--patch");
27-
28-
expect(cli).to.have.stderr("");
29-
expect(cli).to.have.exitCode(0);
30-
31-
expect(cli).to.have.stdout(
32-
`${check} Updated package.json to 0.0.1\n` +
33-
`${check} Updated bower.json to 0.0.1\n` +
34-
`${check} Updated component.json to 0.0.1\n`
35-
);
36-
37-
expect(files.json("package.json")).to.deep.equal({ version: "0.0.1" });
38-
expect(files.json("bower.json")).to.deep.equal({ version: "0.0.1" });
39-
expect(files.json("component.json")).to.deep.equal({ version: "0.0.1" });
40-
});
6+
describe("bump patch", () => {
417

428
it("should increment an all-zero version number", () => {
439
files.create("package.json", { version: "0.0.0" });
4410

45-
let cli = bump("--patch");
11+
let cli = bump("patch");
4612

4713
expect(cli).to.have.stderr("");
4814
expect(cli).to.have.exitCode(0);
@@ -57,7 +23,7 @@ describe.skip("bump --patch", () => {
5723
it("should increment the patch", () => {
5824
files.create("package.json", { version: "1.2.3" });
5925

60-
let cli = bump("--patch");
26+
let cli = bump("patch");
6127

6228
expect(cli).to.have.stderr("");
6329
expect(cli).to.have.exitCode(0);
@@ -72,7 +38,7 @@ describe.skip("bump --patch", () => {
7238
it("should reset the prerelease version", () => {
7339
files.create("package.json", { version: "1.2.3-beta.4" });
7440

75-
let cli = bump("--patch");
41+
let cli = bump("patch");
7642

7743
expect(cli).to.have.stderr("");
7844
expect(cli).to.have.exitCode(0);
@@ -87,7 +53,7 @@ describe.skip("bump --patch", () => {
8753
it("should not be affected by the --preid flag", () => {
8854
files.create("package.json", { version: "1.2.3-beta.4" });
8955

90-
let cli = bump("--patch --preid alpha");
56+
let cli = bump("patch --preid alpha");
9157

9258
expect(cli).to.have.stderr("");
9359
expect(cli).to.have.exitCode(0);
@@ -98,4 +64,21 @@ describe.skip("bump --patch", () => {
9864

9965
expect(files.json("package.json")).to.deep.equal({ version: "1.2.3" });
10066
});
67+
68+
it("should error if there is no existing version number", () => {
69+
files.create("package.json", { name: "my-app" });
70+
files.create("bower.json", { version: "" });
71+
files.create("component.json", { version: 0 });
72+
73+
let cli = bump("patch *.json");
74+
75+
expect(cli).to.have.stdout("");
76+
expect(cli).to.have.stderr("Unable to determine the current version number. Checked bower.json, component.json, package.json.\n");
77+
expect(cli).to.have.exitCode(1);
78+
79+
expect(files.json("package.json")).to.deep.equal({ name: "my-app" });
80+
expect(files.json("bower.json")).to.deep.equal({ version: "" });
81+
expect(files.json("component.json")).to.deep.equal({ version: 0 });
82+
});
83+
10184
});

test/specs/premajor.spec.js

Lines changed: 30 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,99 +3,82 @@
33
const { check, files, bump } = require("../utils");
44
const { expect } = require("chai");
55

6-
describe.skip("bump --premajor", () => {
7-
it("should not increment a non-existent version number", () => {
8-
files.create("package.json", {});
9-
files.create("bower.json", { name: "my-app" });
10-
11-
let cli = bump("--premajor");
12-
13-
expect(cli).to.have.stderr("");
14-
expect(cli).to.have.stdout("");
15-
expect(cli).to.have.exitCode(0);
16-
17-
expect(files.json("package.json")).to.deep.equal({});
18-
expect(files.json("bower.json")).to.deep.equal({ name: "my-app" });
19-
});
20-
21-
it("should treat empty version numbers as 0.0.0", () => {
22-
files.create("package.json", { version: "" });
23-
files.create("bower.json", { version: null });
24-
files.create("component.json", { version: 0 });
25-
26-
let cli = bump("--premajor");
27-
28-
expect(cli).to.have.stderr("");
29-
expect(cli).to.have.exitCode(0);
30-
31-
expect(cli).to.have.stdout(
32-
`${check} Updated package.json to 1.0.0-beta.0\n` +
33-
`${check} Updated bower.json to 1.0.0-beta.0\n` +
34-
`${check} Updated component.json to 1.0.0-beta.0\n`
35-
);
36-
37-
expect(files.json("package.json")).to.deep.equal({ version: "1.0.0-beta.0" });
38-
expect(files.json("bower.json")).to.deep.equal({ version: "1.0.0-beta.0" });
39-
expect(files.json("component.json")).to.deep.equal({ version: "1.0.0-beta.0" });
40-
});
6+
describe("bump premajor", () => {
417

428
it("should increment an all-zero version number", () => {
439
files.create("package.json", { version: "0.0.0" });
4410

45-
let cli = bump("--premajor");
11+
let cli = bump("premajor");
4612

4713
expect(cli).to.have.stderr("");
4814
expect(cli).to.have.exitCode(0);
4915

5016
expect(cli).to.have.stdout(
51-
`${check} Updated package.json to 1.0.0-beta.0\n`
17+
`${check} Updated package.json to 1.0.0-beta.1\n`
5218
);
5319

54-
expect(files.json("package.json")).to.deep.equal({ version: "1.0.0-beta.0" });
20+
expect(files.json("package.json")).to.deep.equal({ version: "1.0.0-beta.1" });
5521
});
5622

5723
it("should reset the minor and patch", () => {
5824
files.create("package.json", { version: "1.2.3" });
5925

60-
let cli = bump("--premajor");
26+
let cli = bump("premajor");
6127

6228
expect(cli).to.have.stderr("");
6329
expect(cli).to.have.exitCode(0);
6430

6531
expect(cli).to.have.stdout(
66-
`${check} Updated package.json to 2.0.0-beta.0\n`
32+
`${check} Updated package.json to 2.0.0-beta.1\n`
6733
);
6834

69-
expect(files.json("package.json")).to.deep.equal({ version: "2.0.0-beta.0" });
35+
expect(files.json("package.json")).to.deep.equal({ version: "2.0.0-beta.1" });
7036
});
7137

7238
it("should reset the prerelease version", () => {
7339
files.create("package.json", { version: "1.2.3-beta.4" });
7440

75-
let cli = bump("--premajor");
41+
let cli = bump("premajor");
7642

7743
expect(cli).to.have.stderr("");
7844
expect(cli).to.have.exitCode(0);
7945

8046
expect(cli).to.have.stdout(
81-
`${check} Updated package.json to 2.0.0-beta.0\n`
47+
`${check} Updated package.json to 2.0.0-beta.1\n`
8248
);
8349

84-
expect(files.json("package.json")).to.deep.equal({ version: "2.0.0-beta.0" });
50+
expect(files.json("package.json")).to.deep.equal({ version: "2.0.0-beta.1" });
8551
});
8652

8753
it("should honor the --preid flag", () => {
8854
files.create("package.json", { version: "1.2.3-beta.4" });
8955

90-
let cli = bump("--premajor --preid alpha");
56+
let cli = bump("premajor --preid alpha");
9157

9258
expect(cli).to.have.stderr("");
9359
expect(cli).to.have.exitCode(0);
9460

9561
expect(cli).to.have.stdout(
96-
`${check} Updated package.json to 2.0.0-alpha.0\n`
62+
`${check} Updated package.json to 2.0.0-alpha.1\n`
9763
);
9864

99-
expect(files.json("package.json")).to.deep.equal({ version: "2.0.0-alpha.0" });
65+
expect(files.json("package.json")).to.deep.equal({ version: "2.0.0-alpha.1" });
10066
});
67+
68+
it("should error if there is no existing version number", () => {
69+
files.create("package.json", { name: "my-app" });
70+
files.create("bower.json", { version: "" });
71+
files.create("component.json", { version: 0 });
72+
73+
let cli = bump("premajor *.json");
74+
75+
expect(cli).to.have.stdout("");
76+
expect(cli).to.have.stderr("Unable to determine the current version number. Checked bower.json, component.json, package.json.\n");
77+
expect(cli).to.have.exitCode(1);
78+
79+
expect(files.json("package.json")).to.deep.equal({ name: "my-app" });
80+
expect(files.json("bower.json")).to.deep.equal({ version: "" });
81+
expect(files.json("component.json")).to.deep.equal({ version: 0 });
82+
});
83+
10184
});

0 commit comments

Comments
 (0)