2022-05-14 20:09:41 +00:00
|
|
|
pub mod support;
|
2022-05-10 20:17:07 +00:00
|
|
|
|
|
|
|
use nu_cli::NuCompleter;
|
|
|
|
use reedline::Completer;
|
|
|
|
use support::{match_suggestions, new_engine};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn flag_completions() {
|
|
|
|
// Create a new engine
|
|
|
|
let (_, _, engine, stack) = new_engine();
|
|
|
|
|
|
|
|
// Instatiate a new completer
|
|
|
|
let mut completer = NuCompleter::new(std::sync::Arc::new(engine), stack);
|
|
|
|
// Test completions for the 'ls' flags
|
2022-06-04 06:47:36 +00:00
|
|
|
let suggestions = completer.complete("ls -", 4);
|
2022-05-10 20:17:07 +00:00
|
|
|
|
2022-07-08 19:15:34 +00:00
|
|
|
assert_eq!(14, suggestions.len());
|
2022-05-10 20:17:07 +00:00
|
|
|
|
|
|
|
let expected: Vec<String> = vec![
|
|
|
|
"--all".into(),
|
2022-07-08 19:15:34 +00:00
|
|
|
"--directory".into(),
|
2022-05-10 20:17:07 +00:00
|
|
|
"--du".into(),
|
|
|
|
"--full-paths".into(),
|
|
|
|
"--help".into(),
|
|
|
|
"--long".into(),
|
|
|
|
"--short-names".into(),
|
2022-07-08 19:15:34 +00:00
|
|
|
"-D".into(),
|
2022-05-10 20:17:07 +00:00
|
|
|
"-a".into(),
|
|
|
|
"-d".into(),
|
|
|
|
"-f".into(),
|
|
|
|
"-h".into(),
|
|
|
|
"-l".into(),
|
|
|
|
"-s".into(),
|
|
|
|
];
|
|
|
|
|
|
|
|
// Match results
|
|
|
|
match_suggestions(expected, suggestions);
|
|
|
|
}
|