2023-07-21 19:15:26 +00:00
|
|
|
mod common;
|
2023-05-23 05:09:11 +00:00
|
|
|
|
2024-05-24 15:13:50 +00:00
|
|
|
use snapbox::assert_data_eq;
|
|
|
|
|
2023-05-23 05:09:11 +00:00
|
|
|
#[test]
|
2023-07-21 19:15:26 +00:00
|
|
|
fn register_completion() {
|
2024-01-15 18:20:57 +00:00
|
|
|
common::register_example::<completest_nu::NuRuntimeBuilder>("static", "test");
|
2023-05-23 05:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2023-07-21 19:15:26 +00:00
|
|
|
fn completion() {
|
|
|
|
let term = completest::Term::new();
|
2024-01-15 18:20:57 +00:00
|
|
|
let mut runtime = common::load_runtime::<completest_nu::NuRuntimeBuilder>("static", "test");
|
2023-07-21 19:15:26 +00:00
|
|
|
|
|
|
|
let input = "test -\t";
|
|
|
|
let expected = r#"% test -
|
|
|
|
--generate generate
|
|
|
|
--global everywhere
|
|
|
|
--help Print help
|
|
|
|
--version Print version
|
|
|
|
-V Print version
|
|
|
|
-h Print help
|
|
|
|
"#;
|
|
|
|
let actual = runtime.complete(input, &term).unwrap();
|
2024-05-24 15:13:50 +00:00
|
|
|
assert_data_eq!(actual, expected);
|
2023-07-21 19:15:26 +00:00
|
|
|
|
|
|
|
let input = "test action -\t";
|
|
|
|
let expected = r#"% test action -
|
|
|
|
--choice enum
|
|
|
|
--count number
|
|
|
|
--global everywhere
|
|
|
|
--help Print help
|
|
|
|
--set value
|
|
|
|
--set-true bool
|
|
|
|
--version Print version
|
|
|
|
-V Print version
|
|
|
|
-h Print help
|
|
|
|
"#;
|
|
|
|
let actual = runtime.complete(input, &term).unwrap();
|
2024-05-24 15:13:50 +00:00
|
|
|
assert_data_eq!(actual, expected);
|
2023-05-23 05:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn completion_value_hint() {
|
2023-07-21 19:15:26 +00:00
|
|
|
let term = completest::Term::new();
|
2024-01-15 18:20:57 +00:00
|
|
|
let mut runtime = common::load_runtime::<completest_nu::NuRuntimeBuilder>("static", "test");
|
2023-07-21 19:15:26 +00:00
|
|
|
|
|
|
|
let input = "test hint -\t";
|
|
|
|
let expected = r#"% test hint -
|
|
|
|
--choice
|
|
|
|
--cmd
|
|
|
|
--cmd-name
|
|
|
|
--dir
|
|
|
|
--email
|
|
|
|
--exe
|
|
|
|
--file
|
|
|
|
--global everywhere
|
|
|
|
--help Print help
|
|
|
|
--host
|
|
|
|
--other
|
|
|
|
--path
|
|
|
|
--unknown
|
|
|
|
--url
|
|
|
|
--user
|
|
|
|
--version Print version
|
|
|
|
-H
|
|
|
|
-V Print version
|
|
|
|
-c
|
|
|
|
-d
|
|
|
|
-e
|
|
|
|
-f
|
|
|
|
-h Print help
|
|
|
|
-p
|
|
|
|
-u
|
|
|
|
"#;
|
|
|
|
let actual = runtime.complete(input, &term).unwrap();
|
2024-05-24 15:13:50 +00:00
|
|
|
assert_data_eq!(actual, expected);
|
2023-07-21 19:15:26 +00:00
|
|
|
|
|
|
|
let input = "test hint --choice \t";
|
|
|
|
let expected = r#"% test hint --choice
|
|
|
|
bash
|
|
|
|
fish
|
|
|
|
zsh
|
|
|
|
"#;
|
|
|
|
let actual = runtime.complete(input, &term).unwrap();
|
2024-05-24 15:13:50 +00:00
|
|
|
assert_data_eq!(actual, expected);
|
2023-05-23 05:09:11 +00:00
|
|
|
}
|