use super::super::common::*;
#[test]
fn test_select_1_auto_selects_single_entry() {
use std::time::Duration;
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"--source-command",
"echo UNIQUE16CHARID",
"--select-1",
]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains_with_timeout(
"UNIQUE16CHARID",
Duration::from_secs(2),
);
}
#[test]
fn test_select_1_respects_initial_input() {
use std::time::Duration;
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"--source-command",
"printf 'television\\ntelescope\\n'",
"--select-1",
"--input",
"telev",
]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains_with_timeout(
"television",
Duration::from_secs(2),
);
}
#[test]
fn test_take_1_auto_selects_first_entry() {
use std::time::Duration;
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"--source-command",
"echo UNIQUE16CHARID",
"--take-1",
]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains_with_timeout(
"UNIQUE16CHARID",
Duration::from_secs(2),
);
}
#[test]
fn test_take_1_fast_auto_selects_first_entry_immediately() {
use std::time::Duration;
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"--source-command",
"echo UNIQUE16CHARID",
"--take-1-fast",
]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains_with_timeout(
"UNIQUE16CHARID",
Duration::from_secs(2),
);
}
#[test]
fn test_select_1_and_take_1_conflict_errors() {
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"files",
"--select-1",
"--take-1",
]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains("cannot be used with");
}
#[test]
fn test_select_1_and_take_1_fast_conflict_errors() {
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"files",
"--select-1",
"--take-1-fast",
]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains("cannot be used with");
}
#[test]
fn test_take_1_and_take_1_fast_conflict_errors() {
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"files",
"--take-1",
"--take-1-fast",
]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains("cannot be used with");
}
#[test]
fn test_watch_and_select_1_conflict_errors() {
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"files",
"--watch",
"1.0",
"--select-1",
]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains("cannot be used with");
}
#[test]
fn test_watch_and_take_1_conflict_errors() {
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"files", "--watch", "1.0", "--take-1",
]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains("cannot be used with");
}
#[test]
fn test_watch_and_take_1_fast_conflict_errors() {
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"files",
"--watch",
"1.0",
"--take-1-fast",
]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains("cannot be used with");
}
#[test]
fn test_expect_with_selection() {
use std::time::Duration;
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"files",
"--expect",
"ctrl-c",
"--input",
"Cargo.toml",
]);
let mut child = tester.spawn_command_tui(cmd);
tester.assert_tui_frame_contains("Cargo.toml");
tester.send(&ctrl('c'));
tester.assert_raw_output_contains_with_timeout(
"ctrl-c\r\nCargo.toml",
Duration::from_secs(2),
);
tester.assert_exit_ok(&mut child, DEFAULT_DELAY);
}