-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
feat(testing): add test for optionDescriptions #4970
feat(testing): add test for optionDescriptions #4970
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4970 +/- ##
==========================================
+ Coverage 70.56% 71.45% +0.89%
==========================================
Files 29 29
Lines 1678 1678
Branches 372 373 +1
==========================================
+ Hits 1184 1199 +15
+ Misses 420 408 -12
+ Partials 74 71 -3
Continue to review full report at Codecov.
|
✨ code-server docs for PR #4970 is ready! It will be updated on every commit.
|
expectedOptionDescriptions.forEach((expectedDescription) => { | ||
const exists = actualOptionDescriptions.find((desc) => { | ||
if ( | ||
desc.replace(/\n/g, " ").replace(/ /g, "").includes(expectedDescription.replace(/\n/g, " ").replace(/ /g, "")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙈 Not proud of this line here but we replace line breaks with spaces, then remove spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about making optionDescriptions
take an argument so we can test specific expectations? And possibly adding nvm it needs to take an array of options otherwise it cannot align them so a single-option function is pretty much uselessoptionDescription
so we can test a single option without having to wrap it in an array.
For example:
it("should display option flag and description", () => {
expect(optionDescriptions([{ type: "boolean": long: "foo", short: "f", description: "a foo flag")}]).toStrictEqual("-f --foo a foo flag")
})
it("should visually align multiple options", () => {
const options = [
{ type: "boolean": long: "foo", short: "f", description: "a foo flag"}
{ type: "string": short: "r", description: "an r flag"}
{ type: "string[]": long: "somethingquitelong"}
]
expect(optionDescriptions(options)).toStrictEqual([
"-f --foo a foo flag",
"-r an r flag"
" --somethingquitelong"
].join("\n")
})
it("should add all valid options for enumerated types", () => {
expect(optionDescriptions([{ type: AuthType: long: "auth", description: "some auth")}]).toStrictEqual(" --foo some auth [password, none]")
})
it("should show if an option is deprecated")
it("should show newlines in description")
@code-asher okay to be extra clear, you're saying I should do this:
and not do this:
right? |
Yes! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done!
* feat(testing): add test for optionDescriptions * refactor(cli): optional arg in optionDescriptions * feat: add more tests for optionDescriptions
This PR adds a test for
optionDescriptions
.Fixes #4915