|
3 | 3 | const { check, files, bump } = require("../utils"); |
4 | 4 | const { expect } = require("chai"); |
5 | 5 |
|
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", () => { |
41 | 7 |
|
42 | 8 | it("should increment an all-zero version number", () => { |
43 | 9 | files.create("package.json", { version: "0.0.0" }); |
44 | 10 |
|
45 | | - let cli = bump("--premajor"); |
| 11 | + let cli = bump("premajor"); |
46 | 12 |
|
47 | 13 | expect(cli).to.have.stderr(""); |
48 | 14 | expect(cli).to.have.exitCode(0); |
49 | 15 |
|
50 | 16 | 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` |
52 | 18 | ); |
53 | 19 |
|
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" }); |
55 | 21 | }); |
56 | 22 |
|
57 | 23 | it("should reset the minor and patch", () => { |
58 | 24 | files.create("package.json", { version: "1.2.3" }); |
59 | 25 |
|
60 | | - let cli = bump("--premajor"); |
| 26 | + let cli = bump("premajor"); |
61 | 27 |
|
62 | 28 | expect(cli).to.have.stderr(""); |
63 | 29 | expect(cli).to.have.exitCode(0); |
64 | 30 |
|
65 | 31 | 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` |
67 | 33 | ); |
68 | 34 |
|
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" }); |
70 | 36 | }); |
71 | 37 |
|
72 | 38 | it("should reset the prerelease version", () => { |
73 | 39 | files.create("package.json", { version: "1.2.3-beta.4" }); |
74 | 40 |
|
75 | | - let cli = bump("--premajor"); |
| 41 | + let cli = bump("premajor"); |
76 | 42 |
|
77 | 43 | expect(cli).to.have.stderr(""); |
78 | 44 | expect(cli).to.have.exitCode(0); |
79 | 45 |
|
80 | 46 | 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` |
82 | 48 | ); |
83 | 49 |
|
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" }); |
85 | 51 | }); |
86 | 52 |
|
87 | 53 | it("should honor the --preid flag", () => { |
88 | 54 | files.create("package.json", { version: "1.2.3-beta.4" }); |
89 | 55 |
|
90 | | - let cli = bump("--premajor --preid alpha"); |
| 56 | + let cli = bump("premajor --preid alpha"); |
91 | 57 |
|
92 | 58 | expect(cli).to.have.stderr(""); |
93 | 59 | expect(cli).to.have.exitCode(0); |
94 | 60 |
|
95 | 61 | 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` |
97 | 63 | ); |
98 | 64 |
|
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" }); |
100 | 66 | }); |
| 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 | + |
101 | 84 | }); |
0 commit comments