-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When user pass an unknown command, try to suggest commands that are c…
…lose
- Loading branch information
Showing
6 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`fuzzValidateCommand should return command is invalid 1`] = ` | ||
lingui: compilesss is unknown | ||
Do you mean: compile ? | ||
`; | ||
|
||
exports[`fuzzValidateCommand should return command is invalid if no commands are configured 1`] = ` | ||
lingui: compile is unknown | ||
`; | ||
|
||
exports[`fuzzValidateCommand should return suggestion for the first command if user passes multiple commands 1`] = ` | ||
lingui: add is unknown | ||
Do you mean: add-strings, add-locales ? | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { fuzzValidateCommand } from "./utils" | ||
|
||
describe("fuzzValidateCommand", function() { | ||
function runFuzzValidateCommand(commandNames, userCommands) { | ||
return fuzzValidateCommand( | ||
commandNames.map(commandName => ({ name: () => commandName })), | ||
userCommands | ||
) | ||
} | ||
|
||
it("should return empty string if user command is valid", function() { | ||
expect(runFuzzValidateCommand(["compile"], ["compile"])).toEqual("") | ||
}) | ||
|
||
it("should return empty string if user passes no command", function() { | ||
expect(runFuzzValidateCommand(["compile"], [])).toEqual("") | ||
}) | ||
|
||
it("should return command is invalid if no commands are configured", function() { | ||
expect(runFuzzValidateCommand([], ["compile"])).toMatchSnapshot() | ||
}) | ||
|
||
it("should return command is invalid", function() { | ||
expect( | ||
runFuzzValidateCommand(["compile"], ["compilesss"]) | ||
).toMatchSnapshot() | ||
}) | ||
|
||
it("should return suggestion for the first command if user passes multiple commands", function() { | ||
expect( | ||
runFuzzValidateCommand(["add-strings", "add-locales"], ["add", "com"]) | ||
).toMatchSnapshot() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters