Skip to content

Commit 66e5459

Browse files
test(complete): cover the option-value handlers
Patch coverage reported 30 uncovered lines, most of them handler bodies that only run while the option they belong to is being completed. Covers `build --progress`, `version --output`, the root `--help`, and the shell argument of `complete` itself. Co-authored-by: AmirSa12 <amirhosseinpr184@gmail.com>
1 parent 6b039e2 commit 66e5459

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

test/complete/complete.test.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,50 @@ describe("complete", () => {
109109
);
110110
});
111111

112+
it("should suggest option values for build --progress", async () => {
113+
const { exitCode, stderr, stdout } = await run(__dirname, [
114+
"complete",
115+
"--",
116+
"build",
117+
"--progress=",
118+
]);
119+
120+
expect(exitCode).toBe(0);
121+
expect(stderr).toBeFalsy();
122+
expect(parseCompletions(stdout)).toEqual(expect.arrayContaining(["profile"]));
123+
});
124+
125+
it("should suggest option values for version --output", async () => {
126+
const { exitCode, stderr, stdout } = await run(__dirname, [
127+
"complete",
128+
"--",
129+
"version",
130+
"--output=",
131+
]);
132+
133+
expect(exitCode).toBe(0);
134+
expect(stderr).toBeFalsy();
135+
expect(parseCompletions(stdout)).toEqual(expect.arrayContaining(["json", "markdown"]));
136+
});
137+
138+
it("should suggest option values for --help", async () => {
139+
const { exitCode, stderr, stdout } = await run(__dirname, ["complete", "--", "--help="]);
140+
141+
expect(exitCode).toBe(0);
142+
expect(stderr).toBeFalsy();
143+
expect(parseCompletions(stdout)).toEqual(expect.arrayContaining(["verbose"]));
144+
});
145+
146+
it("should suggest shells for the complete command", async () => {
147+
const { exitCode, stderr, stdout } = await run(__dirname, ["complete", "--", "complete", ""]);
148+
149+
expect(exitCode).toBe(0);
150+
expect(stderr).toBeFalsy();
151+
expect(parseCompletions(stdout)).toEqual(
152+
expect.arrayContaining(["zsh", "bash", "fish", "powershell"]),
153+
);
154+
});
155+
112156
it("should suggest global options after a command", async () => {
113157
for (const command of ["build", "serve", "help"]) {
114158
const { exitCode, stderr, stdout } = await run(__dirname, ["complete", "--", command, "--"]);

0 commit comments

Comments
 (0)