test(complete): Verify prefix completions

This commit is contained in:
Ed Page 2024-09-04 09:32:21 -05:00
parent 31a4450068
commit c3e5d16183
4 changed files with 102 additions and 0 deletions

View file

@ -281,3 +281,25 @@ fn complete_dynamic_env_quoted_help() {
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
}
#[test]
#[cfg(all(unix, feature = "unstable-dynamic"))]
fn complete_dynamic_env_option_value() {
if !common::has_command("bash") {
return;
}
let term = completest::Term::new();
let mut runtime =
common::load_runtime::<completest_pty::BashRuntimeBuilder>("dynamic-env", "exhaustive");
let input = "exhaustive action --choice=\t\t";
let expected = snapbox::str!["% "];
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
let input = "exhaustive action --choice=f\t";
let expected = snapbox::str!["exhaustive action --choice=f % exhaustive action --choice=f"];
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
}

View file

@ -225,3 +225,33 @@ fn complete_dynamic_env_quoted_help() {
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
}
#[test]
#[cfg(all(unix, feature = "unstable-dynamic"))]
fn complete_dynamic_env_option_value() {
if !common::has_command("elvish") {
return;
}
let term = completest::Term::new();
let mut runtime =
common::load_runtime::<completest_pty::ElvishRuntimeBuilder>("dynamic-env", "exhaustive");
let input = "exhaustive action --choice=\t";
let expected = snapbox::str![[r#"
% exhaustive action '--choice=first'
COMPLETING argument
--choice=first --choice=second
"#]];
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
let input = "exhaustive action --choice=f\t";
let expected = snapbox::str![[r#"
% exhaustive action '--choice=first'
COMPLETING argument
--choice=first
"#]];
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
}

View file

@ -237,3 +237,28 @@ help (Print this message or the help of the given subcommand(s))
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
}
#[test]
#[cfg(all(unix, feature = "unstable-dynamic"))]
fn complete_dynamic_env_option_value() {
if !common::has_command("fish") {
return;
}
let term = completest::Term::new();
let mut runtime =
common::load_runtime::<completest_pty::FishRuntimeBuilder>("dynamic-env", "exhaustive");
let input = "exhaustive action --choice=\t\t";
let expected = snapbox::str![[r#"
% exhaustive action --choice=first
--choice=first --choice=second
"#]];
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
let input = "exhaustive action --choice=f\t";
let expected = snapbox::str!["% exhaustive action --choice=first "];
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
}

View file

@ -211,3 +211,28 @@ fn complete_dynamic_env_quoted_help() {
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
}
#[test]
#[cfg(all(unix, feature = "unstable-dynamic"))]
fn complete_dynamic_env_option_value() {
if !common::has_command("zsh") {
return;
}
let term = completest::Term::new();
let mut runtime =
common::load_runtime::<completest_pty::ZshRuntimeBuilder>("dynamic-env", "exhaustive");
let input = "exhaustive action --choice=\t\t";
let expected = snapbox::str![[r#"
% exhaustive action --choice=
--choice=first --choice=second
"#]];
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
let input = "exhaustive action --choice=f\t\t";
let expected = snapbox::str!["% exhaustive action --choice=first "];
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
}