Skip to content

Commit

Permalink
fix: update tests and error messages
Browse files Browse the repository at this point in the history
It turns out that the combination of testing tools we used before the previous
commit was buggy and did not run all the tests we thought should run! The update
revealed the issue. Since the suite needed updating, we did that and updated
some of the error messages.
  • Loading branch information
lddubeau committed Jun 7, 2018
1 parent a71e685 commit db4d656
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,20 @@ exports.getVersion = Promise.method((filename) => {
* @param {string} filename The name of the file from which to extract a
* version.
*
* @return {VersionInfo} The version information or ``undefined`` if no version
* can be found or if the version is not a valid semver version.
* @return {VersionInfo} The version information.
*
* @throws {InvalidVersionError} If the version is not a valid semver version.
*/
exports.getValidVersion = function getValidVersion(filename) {
return exports.getVersion(filename).then((current) => {
const version = current && current.version;
if (!version) {
throw new InvalidVersionError(`Missing version number in ${filename}.`);
}

if (!semver.valid(version)) {
throw new InvalidVersionError(
`Missing or wrong semver number in ${filename}. Found: ${version}`);
`Invalid semver number in ${filename}. Found: ${version}`);
}

return current;
Expand Down
6 changes: 3 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ describe("Runner", () => {
makeTest("rejects when there is an error", ["package.json", "amd.js"],
runner => assert.isRejected(
runner.verify(), Error,
"Version number is out of sync in amd.js."),
`Version number is out of sync in ${"amd.js".red}.`),
["amd.js"]);
});

Expand Down Expand Up @@ -658,8 +658,8 @@ describe("running versync", () => {

yield execVersync("-v -s invalid.js", true).catch((err) => {
assert.equal(cleanOutput(err.stdout),
"[ERROR] Missing or wrong semver number in " +
"invalid.js. Found: version\n");
"[ERROR] Invalid semver number in invalid.js. " +
"Found: version\n");
});
}));
});

0 comments on commit db4d656

Please sign in to comment.