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

add test for incorrect flags #423

Merged
merged 5 commits into from
Nov 22, 2024
Merged
Changes from 3 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
16 changes: 16 additions & 0 deletions test/general-cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ describe("cli operations", function () {
expect(container.resolve("parseYargs")).to.have.been.calledOnce;
});

it("should exit with a helpful message if a non-existant flag is not provided", async function () {
cleve-fauna marked this conversation as resolved.
Show resolved Hide resolved
const logger = container.resolve("logger");

// the halflight flag doesn't exist
try {
await run(`schema pull --secret "secret" --halflight`, container);
} catch (e) {}

expect(logger.stdout).to.not.be.called;
const message = `${chalk.reset(await builtYargs.getHelp())}\n\n${chalk.red(
"Unknown argument: halflight",
)}`;
expect(logger.stderr).to.have.been.calledWith(message);
expect(container.resolve("parseYargs")).to.have.been.calledOnce;
});

// TODO: this doesn't work because turning on strict mode breaks parsing sub-commands. why?
it("should exit with a helpful message if a non-existent command is provided", async function () {
const logger = container.resolve("logger");
Expand Down