Skip to content

Commit 3b958ee

Browse files
test: more
1 parent bcbb590 commit 3b958ee

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

test/api/CLI.test.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,5 +1643,60 @@ describe("CLI API", () => {
16431643

16441644
command.parseAsync(["--unknown", "foo"], { from: "user" });
16451645
});
1646+
1647+
it("should make command with Boolean option and use description", async () => {
1648+
expect.assertions(2);
1649+
1650+
cli.program.commands = [];
1651+
1652+
const command = await cli.makeCommand(
1653+
{
1654+
name: "command",
1655+
},
1656+
[
1657+
{
1658+
name: "boolean",
1659+
type: Boolean,
1660+
description: "Description",
1661+
negatedDescription: "Negated description",
1662+
},
1663+
],
1664+
(options) => {
1665+
expect(options).toEqual({ boolean: true });
1666+
},
1667+
);
1668+
1669+
command.parseAsync(["--boolean"], { from: "user" });
1670+
1671+
expect(command.helpInformation()).toContain("--boolean Description");
1672+
});
1673+
1674+
it("should make command with Boolean option and negative value and use negatedDescription", async () => {
1675+
expect.assertions(2);
1676+
1677+
cli.program.commands = [];
1678+
1679+
const command = await cli.makeCommand(
1680+
{
1681+
name: "command",
1682+
},
1683+
[
1684+
{
1685+
name: "boolean",
1686+
type: Boolean,
1687+
description: "description",
1688+
negative: true,
1689+
negatedDescription: "Negated description",
1690+
},
1691+
],
1692+
(options) => {
1693+
expect(options).toEqual({ boolean: false });
1694+
},
1695+
);
1696+
1697+
command.parseAsync(["--no-boolean"], { from: "user" });
1698+
1699+
expect(command.helpInformation()).toContain("--no-boolean Negated description");
1700+
});
16461701
});
16471702
});

0 commit comments

Comments
 (0)