Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 249 fixed and other enums refactored #264

Merged
merged 2 commits into from
Feb 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bin/config-yargs.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ module.exports = function(yargs) {
},
mode: {
type: "string",
describe: "Mode to use (production or development)",
choices: ["development", "production"],
describe: "Mode to use",
group: CONFIG_GROUP,
requiresArg: true
},
Expand Down
11 changes: 4 additions & 7 deletions bin/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@
},
display: {
type: "string",
choices: ["", "verbose", "detailed", "normal", "minimal", "errors-only", "none"],
group: DISPLAY_GROUP,
describe:
"Select display preset (verbose, detailed, normal, minimal, errors-only, none)"
describe: "Select display preset"
},
verbose: {
type: "boolean",
Expand All @@ -191,9 +191,10 @@
"info-verbosity": {
type: "string",
default: "info",
choices: ["none", "info", "verbose"],
group: DISPLAY_GROUP,
describe:
"Controls the output of lifecycle messaging e.g. Started watching files... (verbose, info, none)"
"Controls the output of lifecycle messaging e.g. Started watching files..."
}
});

Expand Down Expand Up @@ -407,10 +408,6 @@
});

ifArg("info-verbosity", function(value) {
if (!["none", "info", "verbose"].includes(value))
throw new Error(
"Invalid configuration object. \n configuration['info-verbosity'] should be one of these:\n \"none\" | \"info\" | \"verbose\""
);
outputOptions.infoVerbosity = value;
});

Expand Down
5 changes: 2 additions & 3 deletions test/binCases/errors/info-verbosity/stdin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use strict";

module.exports = function testAssertions(code, stdout, stderr) {
expect(stderr[3]).toContain("Error: Invalid configuration object.");
expect(stderr[4]).toContain("configuration['info-verbosity'] should be one of these:");
expect(stderr[5]).toContain("\"none\" | \"info\" | \"verbose\"");
expect(stderr[stderr.length - 3]).toContain("Invalid values:");
expect(stderr[stderr.length - 2]).toContain(" Argument: info-verbosity, Given: \"false\", Choices: \"none\", \"info\", \"verbose\"");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be done without slicing at the end of the array? If you already know the size of it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Total length will vary because adding more options into yargs.options will change the total length as invalid options do print out the whole usage info, but i know that -3 and -2 will be error specific values that i want to check

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha, but the tests are static, yes? So the size will always be constant

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless there's 9 different tests for 1 case here ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Size will change if anyone update unrelated option here and it will require this test case update.
I mean this unrelated options will increase/decrease the output line count as all of them are printed on invalid option

silent: {
type: "boolean",
describe: "Prevent output from being displayed in stdout"
},
json: {
type: "boolean",
alias: "j",
describe: "Prints the result as JSON."
},
progress: {
type: "boolean",
describe: "Print compilation progress in percentage",
group: BASIC_GROUP
},
color: {
type: "boolean",
alias: "colors",
default: function supportsColor() {
return require("supports-color");
},
group: DISPLAY_GROUP,
describe: "Enables/Disables colors on the console"
},
"sort-modules-by": {
type: "string",
group: DISPLAY_GROUP,
describe: "Sorts the modules list by property in module"
},

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while the actual error is at the end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is unrelated option in this case? You mean flags?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah sorry, so any update to their description or removal\addition will change lines amount

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right. Let's keep it for now, could change it later if needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, thank you!

};