Skip to content

Commit e822206

Browse files
Replaced Chai's .should() syntax with expect() syntax
1 parent 420ffe0 commit e822206

17 files changed

Lines changed: 357 additions & 360 deletions

test/specs/api.spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const versionBump = require("../../");
44
const { files, mocks } = require("../utils");
5-
const { expect } = require("../utils/chai");
5+
const { expect } = require("chai");
66

77
const ORIGINAL_CWD = process.cwd();
88

@@ -20,7 +20,7 @@ describe("versionBup() API", () => {
2020

2121
let results = await versionBump("2.34.567");
2222

23-
results.should.deep.equal({
23+
expect(results).to.deep.equal({
2424
release: undefined,
2525
oldVersion: "1.0.0",
2626
newVersion: "2.34.567",
@@ -45,7 +45,7 @@ describe("versionBup() API", () => {
4545

4646
let results = await versionBump("minor");
4747

48-
results.should.deep.equal({
48+
expect(results).to.deep.equal({
4949
release: "minor",
5050
oldVersion: "1.0.0",
5151
newVersion: "1.1.0",
@@ -84,7 +84,7 @@ describe("versionBup() API", () => {
8484
]
8585
});
8686

87-
results.should.deep.equal({
87+
expect(results).to.deep.equal({
8888
release: "preminor",
8989
oldVersion: "1.0.0",
9090
newVersion: "1.1.0-test.1",
@@ -108,14 +108,14 @@ describe("versionBup() API", () => {
108108

109109
files.text("subdir/deep/changelog.md", "# Changelog\n\n## v1.1.0-test.1\n\n## v0.0.1\n");
110110

111-
files.json("random-file.json").should.deep.equal({
111+
expect(files.json("random-file.json")).to.deep.equal({
112112
name: "v1.1.0-test.1",
113113
version: "1.1.0-test.1",
114114
desc: "This is version 1.1.0-test.1.",
115115
});
116116

117117
// A git commit and tag should have been created
118-
mocks.git().should.deep.equal([
118+
expect(mocks.git()).to.deep.equal([
119119
'git commit --message "A test of the upcoming v1.1.0-test.1" random-file.json README.md subdir/deep/changelog.md',
120120
'git tag --annotate --message "A test of the upcoming v1.1.0-test.1" 1.1.0-test.1',
121121
]);
@@ -154,7 +154,7 @@ describe("versionBup() API", () => {
154154
}
155155
catch (error) {
156156
expect(error).to.be.an.instanceOf(Error);
157-
error.message.should.equal(
157+
expect(error.message).to.equal(
158158
"Unable to determine the current version number. Checked package.json."
159159
);
160160

test/specs/cli.spec.js

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22

3-
const { files } = require("../utils");
4-
const { chaiExec, expect } = require("../utils/chai");
3+
const { files, bump } = require("../utils");
4+
const { expect } = require("chai");
55
const manifest = require("../../package.json");
66

77
describe("bump", () => {
@@ -13,110 +13,110 @@ describe("bump", () => {
1313
// Run the CLI without any arguments.
1414
// It will prompt the user and wait forever, so add a timeout.
1515
this.timeout(Math.max(10000, this.timeout()));
16-
let bump = chaiExec("", { timeout: 6000 });
16+
let cli = bump("", { timeout: 6000 });
1717

1818
// It should have prompted for input
19-
expect(bump.stdout).to.contain("The current version in package.json is 1.0.0\nHow would you like to bump it? (Use arrow keys)");
19+
expect(cli.stdout).to.contain("The current version in package.json is 1.0.0\nHow would you like to bump it? (Use arrow keys)");
2020
});
2121

2222
it("should error if an invalid argument is used", () => {
23-
let bump = chaiExec("--commit --help --fizzbuzz --quiet");
23+
let cli = bump("--commit --help --fizzbuzz --quiet");
2424

25-
expect(bump).to.have.exitCode(9);
26-
expect(bump).to.have.stdout("");
27-
expect(bump.stderr).to.match(/^Unknown option: --fizzbuzz\n\nUsage: bump \[release\] \[options\] \[files...\]\n/);
28-
expect(bump.stderr).to.contain(manifest.description);
25+
expect(cli).to.have.exitCode(9);
26+
expect(cli).to.have.stdout("");
27+
expect(cli.stderr).to.match(/^Unknown option: --fizzbuzz\n\nUsage: bump \[release\] \[options\] \[files...\]\n/);
28+
expect(cli.stderr).to.contain(manifest.description);
2929
});
3030

3131
it("should error if an invalid shorthand argument is used", () => {
32-
let bump = chaiExec("-cqhzt");
32+
let cli = bump("-cqhzt");
3333

34-
expect(bump).to.have.exitCode(9);
35-
expect(bump).to.have.stdout("");
36-
expect(bump.stderr).to.match(/^Unknown option: -z\n\nUsage: bump \[release\] \[options\] \[files...\]\n/);
37-
expect(bump.stderr).to.contain(manifest.description);
34+
expect(cli).to.have.exitCode(9);
35+
expect(cli).to.have.stdout("");
36+
expect(cli.stderr).to.match(/^Unknown option: -z\n\nUsage: bump \[release\] \[options\] \[files...\]\n/);
37+
expect(cli.stderr).to.contain(manifest.description);
3838
});
3939

4040
it("should error if an argument is missing its value", () => {
41-
let bump = chaiExec("--commit --help --preid --quiet");
41+
let cli = bump("--commit --help --preid --quiet");
4242

43-
expect(bump).to.have.exitCode(9);
44-
expect(bump).to.have.stdout("");
45-
bump.stderr.should.match(
43+
expect(cli).to.have.exitCode(9);
44+
expect(cli).to.have.stdout("");
45+
expect(cli.stderr).to.match(
4646
/^The --preid option requires a value, such as "alpha", "beta", etc\.\n\nUsage: bump \[release\] \[options\] \[files...\]\n/
4747
);
48-
expect(bump.stderr).to.contain(manifest.description);
48+
expect(cli.stderr).to.contain(manifest.description);
4949
});
5050

5151
describe("bump --help", () => {
5252
it("should show usage text", () => {
53-
let bump = chaiExec("--help");
53+
let cli = bump("--help");
5454

55-
expect(bump).to.have.exitCode(0);
56-
expect(bump).to.have.stderr("");
57-
expect(bump.stdout).to.match(/^\nUsage: bump \[release\] \[options\] \[files...\]\n/);
58-
expect(bump.stdout).to.contain(manifest.description);
55+
expect(cli).to.have.exitCode(0);
56+
expect(cli).to.have.stderr("");
57+
expect(cli.stdout).to.match(/^\nUsage: bump \[release\] \[options\] \[files...\]\n/);
58+
expect(cli.stdout).to.contain(manifest.description);
5959
});
6060

6161
it("should support -h shorthand", () => {
62-
let bump = chaiExec("-h");
62+
let cli = bump("-h");
6363

64-
expect(bump).to.have.exitCode(0);
65-
expect(bump).to.have.stderr("");
66-
expect(bump.stdout).to.match(/^\nUsage: bump \[release\] \[options\] \[files...\]\n/);
67-
expect(bump.stdout).to.contain(manifest.description);
64+
expect(cli).to.have.exitCode(0);
65+
expect(cli).to.have.stderr("");
66+
expect(cli.stdout).to.match(/^\nUsage: bump \[release\] \[options\] \[files...\]\n/);
67+
expect(cli.stdout).to.contain(manifest.description);
6868
});
6969

7070
it("should ignore other arguments", () => {
71-
let bump = chaiExec("--quiet --help --tag");
71+
let cli = bump("--quiet --help --tag");
7272

73-
expect(bump).to.have.exitCode(0);
74-
expect(bump).to.have.stderr("");
75-
expect(bump.stdout).to.match(/^\nUsage: bump \[release\] \[options\] \[files...\]\n/);
76-
expect(bump.stdout).to.contain(manifest.description);
73+
expect(cli).to.have.exitCode(0);
74+
expect(cli).to.have.stderr("");
75+
expect(cli.stdout).to.match(/^\nUsage: bump \[release\] \[options\] \[files...\]\n/);
76+
expect(cli.stdout).to.contain(manifest.description);
7777
});
7878

7979
it("should ignore other shorthand arguments", () => {
80-
let bump = chaiExec("-cht");
80+
let cli = bump("-cht");
8181

82-
expect(bump).to.have.exitCode(0);
83-
expect(bump).to.have.stderr("");
84-
expect(bump.stdout).to.match(/^\nUsage: bump \[release\] \[options\] \[files...\]\n/);
85-
expect(bump.stdout).to.contain(manifest.description);
82+
expect(cli).to.have.exitCode(0);
83+
expect(cli).to.have.stderr("");
84+
expect(cli.stdout).to.match(/^\nUsage: bump \[release\] \[options\] \[files...\]\n/);
85+
expect(cli.stdout).to.contain(manifest.description);
8686
});
8787
});
8888

8989
describe("bump --version", () => {
9090
it("should show the version number", () => {
91-
let bump = chaiExec("--version");
91+
let cli = bump("--version");
9292

93-
expect(bump).to.have.exitCode(0);
94-
expect(bump).to.have.stderr("");
95-
expect(bump).to.have.stdout(manifest.version + "\n");
93+
expect(cli).to.have.exitCode(0);
94+
expect(cli).to.have.stderr("");
95+
expect(cli).to.have.stdout(manifest.version + "\n");
9696
});
9797

9898
it("should support -v shorthand", () => {
99-
let bump = chaiExec("-v");
99+
let cli = bump("-v");
100100

101-
expect(bump).to.have.exitCode(0);
102-
expect(bump).to.have.stderr("");
103-
expect(bump).to.have.stdout(manifest.version + "\n");
101+
expect(cli).to.have.exitCode(0);
102+
expect(cli).to.have.stderr("");
103+
expect(cli).to.have.stdout(manifest.version + "\n");
104104
});
105105

106106
it("should ignore other arguments", () => {
107-
let bump = chaiExec("--quiet --version --tag");
107+
let cli = bump("--quiet --version --tag");
108108

109-
expect(bump).to.have.exitCode(0);
110-
expect(bump).to.have.stderr("");
111-
expect(bump).to.have.stdout(manifest.version + "\n");
109+
expect(cli).to.have.exitCode(0);
110+
expect(cli).to.have.stderr("");
111+
expect(cli).to.have.stdout(manifest.version + "\n");
112112
});
113113

114114
it("should ignore other shorthand arguments", () => {
115-
let bump = chaiExec("-cvt");
115+
let cli = bump("-cvt");
116116

117-
expect(bump).to.have.exitCode(0);
118-
expect(bump).to.have.stderr("");
119-
expect(bump).to.have.stdout(manifest.version + "\n");
117+
expect(cli).to.have.exitCode(0);
118+
expect(cli).to.have.stderr("");
119+
expect(cli).to.have.stdout(manifest.version + "\n");
120120
});
121121
});
122122
});

test/specs/exports.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22

33
const commonJSExport = require("../../");
4-
const { expect } = require("../utils/chai");
4+
const { expect } = require("chai");
55
const { default: defaultExport, versionBump: namedExport } = require("../../");
66

77
describe("version-bump-prompt package exports", () => {
@@ -22,7 +22,7 @@ describe("version-bump-prompt package exports", () => {
2222
});
2323

2424
it("should not export anything else", () => {
25-
Object.keys(commonJSExport).should.have.same.members([
25+
expect(Object.keys(commonJSExport)).to.have.same.members([
2626
"default",
2727
"versionBump",
2828
]);

test/specs/files.spec.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
"use strict";
22

3-
const { check, files, fixtures } = require("../utils");
4-
const { chaiExec, expect } = require("../utils/chai");
3+
const { check, files, fixtures, bump } = require("../utils");
4+
const { expect } = require("chai");
55

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

88
it("should update the package.json and package-lock.json by default", () => {
99
files.create("package.json", { version: "1.2.3" });
1010
files.create("package-lock.json", { version: "1.2.3" });
1111

12-
let bump = chaiExec("major");
12+
let cli = bump("major");
1313

14-
expect(bump).to.have.stderr("");
15-
expect(bump).to.have.exitCode(0);
14+
expect(cli).to.have.stderr("");
15+
expect(cli).to.have.exitCode(0);
1616

17-
bump.should.have.stdout(
17+
expect(cli).to.have.stdout(
1818
`${check} Updated package.json to 2.0.0\n` +
1919
`${check} Updated package-lock.json to 2.0.0\n`
2020
);
@@ -27,12 +27,12 @@ describe.skip("bump [files...]", () => {
2727
files.create("package.json", { version: "1.2.3" });
2828
files.create("package-lock.json", { version: "1.2.3" });
2929

30-
let bump = chaiExec("major");
30+
let cli = bump("major");
3131

32-
expect(bump).to.have.stderr("");
33-
expect(bump).to.have.exitCode(0);
32+
expect(cli).to.have.stderr("");
33+
expect(cli).to.have.exitCode(0);
3434

35-
bump.should.have.stdout(
35+
expect(cli).to.have.stdout(
3636
`${check} Updated package.json to 2.0.0\n` +
3737
`${check} Updated package-lock.json to 2.0.0\n`
3838
);
@@ -50,12 +50,12 @@ describe.skip("bump [files...]", () => {
5050
files.create("subdir/deep/script1.js", fixtures.script1);
5151
files.create("subdir/deep/script2.js", fixtures.script2);
5252

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

55-
expect(bump).to.have.stderr("");
56-
expect(bump).to.have.exitCode(0);
55+
expect(cli).to.have.stderr("");
56+
expect(cli).to.have.exitCode(0);
5757

58-
bump.should.have.stdout(
58+
expect(cli).to.have.stdout(
5959
`${check} Updated LICENSE to 2.0.0\n` +
6060
`${check} Updated README.md to 2.0.0\n` +
6161
`${check} Updated script1.js to 2.0.0\n`
@@ -73,12 +73,12 @@ describe.skip("bump [files...]", () => {
7373
files.create("package.json", { version: "1.2.3", notTheVersion: "1.2.3" });
7474
files.create("package-lock.json", { version: "1.2.3", notTheVersion: "1.2.3" });
7575

76-
let bump = chaiExec("major");
76+
let cli = bump("major");
7777

78-
expect(bump).to.have.stderr("");
79-
expect(bump).to.have.exitCode(0);
78+
expect(cli).to.have.stderr("");
79+
expect(cli).to.have.exitCode(0);
8080

81-
bump.should.have.stdout(
81+
expect(cli).to.have.stdout(
8282
`${check} Updated package.json to 2.0.0\n` +
8383
`${check} Updated package-lock.json to 2.0.0\n`
8484
);
@@ -95,12 +95,12 @@ describe.skip("bump [files...]", () => {
9595
files.create("script1.js", fixtures.script1);
9696
files.create("script2.js", fixtures.script2);
9797

98-
let bump = chaiExec("major LICENSE README.* *.js");
98+
let cli = bump("major LICENSE README.* *.js");
9999

100-
expect(bump).to.have.stderr("");
101-
expect(bump).to.have.exitCode(0);
100+
expect(cli).to.have.stderr("");
101+
expect(cli).to.have.exitCode(0);
102102

103-
bump.should.have.stdout(
103+
expect(cli).to.have.stdout(
104104
`${check} Updated package.json to 2.0.0\n` +
105105
`${check} Updated README.md to 2.0.0\n` +
106106
`${check} Updated script1.js to 2.0.0\n` +
@@ -118,12 +118,12 @@ describe.skip("bump [files...]", () => {
118118
files.create("script1.js", fixtures.script1);
119119
files.create("script2.js", fixtures.script2);
120120

121-
let bump = chaiExec("major LICENSE README.* *.js");
121+
let cli = bump("major LICENSE README.* *.js");
122122

123-
expect(bump).to.have.stderr("");
124-
expect(bump).to.have.exitCode(0);
123+
expect(cli).to.have.stderr("");
124+
expect(cli).to.have.exitCode(0);
125125

126-
bump.should.have.stdout(
126+
expect(cli).to.have.stdout(
127127
`${check} Updated package.json to 5.0.0\n`
128128
);
129129

@@ -140,12 +140,12 @@ describe.skip("bump [files...]", () => {
140140
it("should error if an explicitly-specified file doesn't exist", () => {
141141
files.create("package.json", { version: "4.5.6" });
142142

143-
let bump = chaiExec("major LICENSE README.* *.js");
143+
let cli = bump("major LICENSE README.* *.js");
144144

145-
expect(bump).to.have.stderr("");
146-
expect(bump).to.have.exitCode(0);
145+
expect(cli).to.have.stderr("");
146+
expect(cli).to.have.exitCode(0);
147147

148-
bump.should.have.stdout(
148+
expect(cli).to.have.stdout(
149149
`${check} Updated package.json to 5.0.0\n`
150150
);
151151

@@ -162,12 +162,12 @@ describe.skip("bump [files...]", () => {
162162
it("should error if a glob pattern doesn't match any files", () => {
163163
files.create("package.json", { version: "4.5.6" });
164164

165-
let bump = chaiExec("major README.* *.js");
165+
let cli = bump("major README.* *.js");
166166

167-
expect(bump).to.have.stderr("");
168-
expect(bump).to.have.exitCode(0);
167+
expect(cli).to.have.stderr("");
168+
expect(cli).to.have.exitCode(0);
169169

170-
bump.should.have.stdout(
170+
expect(cli).to.have.stdout(
171171
`${check} Updated package.json to 5.0.0\n`
172172
);
173173

0 commit comments

Comments
 (0)