test(complete): Use more snapshotting

This commit is contained in:
Ed Page 2024-08-28 21:29:05 -05:00
parent 32ed967a0a
commit d51922c79e
2 changed files with 13 additions and 7 deletions

View file

@ -171,15 +171,17 @@ fn complete() {
common::load_runtime::<completest_pty::BashRuntimeBuilder>("static", "exhaustive");
let input = "exhaustive \t\t";
let expected = r#"%
let expected = snapbox::str![[r#"
%
-h --global --help action value last hint help
-V --generate --version quote pacman alias complete "#;
-V --generate --version quote pacman alias complete
"#]];
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
// Issue 5239 (https://github.com/clap-rs/clap/issues/5239)
let input = "exhaustive hint --file test\t";
let expected = "exhaustive hint --file test % exhaustive hint --file tests/";
let expected = snapbox::str!["exhaustive hint --file test % exhaustive hint --file tests/"];
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);

View file

@ -152,16 +152,20 @@ fn complete() {
common::load_runtime::<completest_pty::FishRuntimeBuilder>("static", "exhaustive");
let input = "exhaustive \t";
let expected = r#"% exhaustive
let expected = snapbox::str![[r#"
% exhaustive
action complete (Register shell completions for this program) hint pacman value
alias help (Print this message or the help of the given subcommand(s)) last quote "#;
alias help (Print this message or the help of the given subcommand(s)) last quote
"#]];
let actual = runtime.complete(input, &term).unwrap();
assert_data_eq!(actual, expected);
let input = "exhaustive quote --choice \t";
let actual = runtime.complete(input, &term).unwrap();
let expected = r#"% exhaustive quote --choice
bash (bash (shell)) fish (fish shell) zsh (zsh shell)"#;
let expected = snapbox::str![[r#"
% exhaustive quote --choice
bash (bash (shell)) fish (fish shell) zsh (zsh shell)
"#]];
assert_data_eq!(actual, expected);
}