Skip to content

Commit

Permalink
Add test for help messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dyedgreen committed Dec 27, 2021
1 parent 921a15a commit 27939ae
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/command_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ Deno.test("basic command errors", () => {
});
});

Deno.test("help messages shows closest flag", () => {
const cmd = new Command("A test command.")
.required(string, "test", { flags: ["test"] });

let message = "";
try {
cmd.parse(["--tst", "test"]);
} catch (error) {
message = error.message;
}
assertEquals(
message,
"Unknown flag '--tst'\n\nHELP:\n\tDid you mean --test?",
);
});

Deno.test("can not have multiple anonymous optional arguments", () => {
assertThrows(() =>
new Command("A test command.").optional(string, "first").optional(
Expand Down

0 comments on commit 27939ae

Please sign in to comment.