mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
test(cli): share instructions completion fixtures (#16330)
This commit is contained in:
1 parent
175fc298af
commit
34599ec5ff
1 file changed
+26
-39
@@ -56,6 +56,9 @@ const complete = (words: string[], index = words.length - 1) => {
|
||||
.map((value) => (value.endsWith("\x01") ? value.slice(0, -1) : value));
|
||||
};
|
||||
|
||||
const completeInstructions = (...words: string[]) =>
|
||||
complete(["rea", "instructions", ...words]);
|
||||
|
||||
const completeBash = (
|
||||
line: string,
|
||||
fragment: string,
|
||||
@@ -79,21 +82,19 @@ it("resolves enabled builtin scopes in the same tree as registered commands", ()
|
||||
});
|
||||
|
||||
it("uses canonical global flag metadata and retains command options and enum hints", () => {
|
||||
expect(complete(["rea", "instructions", "--", "--he"])).toEqual([]);
|
||||
expect(complete(["rea", "instructions", "--he"])).toEqual(["--help"]);
|
||||
expect(complete(["rea", "instructions", "--for"])).toEqual(["--format"]);
|
||||
expect(complete(["rea", "instructions", "--tok"])).toEqual(
|
||||
expect(completeInstructions("--", "--he")).toEqual([]);
|
||||
expect(completeInstructions("--he")).toEqual(["--help"]);
|
||||
expect(completeInstructions("--for")).toEqual(["--format"]);
|
||||
expect(completeInstructions("--tok")).toEqual(
|
||||
expect.arrayContaining([
|
||||
"--token-count",
|
||||
"--token-limit",
|
||||
"--token-offset",
|
||||
]),
|
||||
);
|
||||
expect(complete(["rea", "instructions", "--proc"])).toEqual(["--procedure"]);
|
||||
expect(complete(["rea", "instructions", "--target-format", "--he"])).toEqual([
|
||||
"--help",
|
||||
]);
|
||||
expect(complete(["rea", "instructions", "--target-format", ""])).toEqual([
|
||||
expect(completeInstructions("--proc")).toEqual(["--procedure"]);
|
||||
expect(completeInstructions("--target-format", "--he")).toEqual(["--help"]);
|
||||
expect(completeInstructions("--target-format", "")).toEqual([
|
||||
"dos-com",
|
||||
"raw-binary",
|
||||
]);
|
||||
@@ -111,10 +112,8 @@ it("uses canonical global flag metadata and retains command options and enum hin
|
||||
"mcp",
|
||||
"completions",
|
||||
]);
|
||||
expect(complete(["rea", "instructions", "--"])).not.toContain(
|
||||
"--incur-update-check",
|
||||
);
|
||||
expect(complete(["rea", "instructions", "--"])).not.toContain("--mcp");
|
||||
expect(completeInstructions("--")).not.toContain("--incur-update-check");
|
||||
expect(completeInstructions("--")).not.toContain("--mcp");
|
||||
});
|
||||
|
||||
it("completes whole-word inline values with their option spelling", () => {
|
||||
@@ -123,36 +122,24 @@ it("completes whole-word inline values with their option spelling", () => {
|
||||
completionOutput("nushell", ["rea", "instructions", "--format=j"]),
|
||||
),
|
||||
).toEqual([{ value: "--format=json" }, { value: "--format=jsonl" }]);
|
||||
expect(complete(["rea", "instructions", "--target-format="])).toEqual([
|
||||
expect(completeInstructions("--target-format=")).toEqual([
|
||||
"--target-format=dos-com",
|
||||
"--target-format=raw-binary",
|
||||
]);
|
||||
expect(complete(["rea", "instructions", "--targetFormat=r"])).toEqual([]);
|
||||
expect(complete(["rea", "instructions", "-f", "r"])).toEqual(["raw-binary"]);
|
||||
expect(complete(["rea", "instructions", "-f=r"])).toEqual([]);
|
||||
expect(completeInstructions("--targetFormat=r")).toEqual([]);
|
||||
expect(completeInstructions("-f", "r")).toEqual(["raw-binary"]);
|
||||
expect(completeInstructions("-f=r")).toEqual([]);
|
||||
expect(completeInstructions("example.f", "--target-format=r")).toEqual([
|
||||
"--target-format=raw-binary",
|
||||
]);
|
||||
expect(completeInstructions("--no-dry-run", "--target-format=r")).toEqual([
|
||||
"--target-format=raw-binary",
|
||||
]);
|
||||
expect(
|
||||
complete(["rea", "instructions", "example.f", "--target-format=r"]),
|
||||
).toEqual(["--target-format=raw-binary"]);
|
||||
expect(
|
||||
complete(["rea", "instructions", "--no-dry-run", "--target-format=r"]),
|
||||
).toEqual(["--target-format=raw-binary"]);
|
||||
expect(
|
||||
complete([
|
||||
"rea",
|
||||
"instructions",
|
||||
"example.bin",
|
||||
"--procedure",
|
||||
"--target-format=r",
|
||||
]),
|
||||
completeInstructions("example.bin", "--procedure", "--target-format=r"),
|
||||
).toEqual([]);
|
||||
expect(
|
||||
complete([
|
||||
"rea",
|
||||
"instructions",
|
||||
"--procedure",
|
||||
"--target-format",
|
||||
"--target-format=r",
|
||||
]),
|
||||
completeInstructions("--procedure", "--target-format", "--target-format=r"),
|
||||
).toEqual(["--target-format=raw-binary"]);
|
||||
for (const word of [
|
||||
"--unknown=j",
|
||||
@@ -160,8 +147,8 @@ it("completes whole-word inline values with their option spelling", () => {
|
||||
"--help=t",
|
||||
"--format=j=",
|
||||
])
|
||||
expect(complete(["rea", "instructions", word])).toEqual([]);
|
||||
expect(complete(["rea", "instructions", "--", "--format=j"])).toEqual([]);
|
||||
expect(completeInstructions(word)).toEqual([]);
|
||||
expect(completeInstructions("--", "--format=j")).toEqual([]);
|
||||
expect(
|
||||
JSON.parse(
|
||||
completionOutput("nushell", [
|
||||
|
||||
Reference in new issue
Block a user