use super::super::common::*;
#[test]
fn test_select_1_auto_selects_single_entry() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(
&pt,
&["--source-command", "echo UNIQUE16CHARID", "--select-1"],
)
.start()
.unwrap();
let output = exit_and_output(&s);
assert!(
output.contains("UNIQUE16CHARID"),
"expected output to contain 'UNIQUE16CHARID', got:\n{output}"
);
}
#[test]
fn test_select_1_respects_initial_input() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(
&pt,
&[
"--source-command",
"printf 'television\\ntelescope\\n'",
"--select-1",
"--input",
"telev",
],
)
.start()
.unwrap();
let output = exit_and_output(&s);
assert!(
output.contains("television"),
"expected output to contain 'television', got:\n{output}"
);
}
#[test]
fn test_take_1_auto_selects_first_entry() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(
&pt,
&["--source-command", "echo UNIQUE16CHARID", "--take-1"],
)
.start()
.unwrap();
let output = exit_and_output(&s);
assert!(
output.contains("UNIQUE16CHARID"),
"expected output to contain 'UNIQUE16CHARID', got:\n{output}"
);
}
#[test]
fn test_take_1_fast_auto_selects_first_entry_immediately() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(
&pt,
&["--source-command", "echo UNIQUE16CHARID", "--take-1-fast"],
)
.start()
.unwrap();
let output = exit_and_output(&s);
assert!(
output.contains("UNIQUE16CHARID"),
"expected output to contain 'UNIQUE16CHARID', got:\n{output}"
);
}
#[test]
fn test_take_1_fast_flushes_before_source_completion() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(
&pt,
&[
"--source-command",
"sleep 0.2 ; echo UNIQUE16CHARID_FIRST ; sleep 4 ; echo UNIQUE16CHARID_SECOND",
"--take-1",
],
)
.start()
.unwrap();
let output = exit_and_output(&s);
assert!(
output.contains("UNIQUE16CHARID_FIRST"),
"expected output to contain 'UNIQUE16CHARID_FIRST', got:\n{output}"
);
}
#[test]
fn test_select_1_and_take_1_conflict_errors() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(
&pt,
&["files", "--select-1", "--take-1"],
)
.start()
.unwrap();
s.wait().text("cannot be used with").until().unwrap();
}
#[test]
fn test_select_1_and_take_1_fast_conflict_errors() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(
&pt,
&["files", "--select-1", "--take-1-fast"],
)
.start()
.unwrap();
s.wait().text("cannot be used with").until().unwrap();
}
#[test]
fn test_take_1_and_take_1_fast_conflict_errors() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(
&pt,
&["files", "--take-1", "--take-1-fast"],
)
.start()
.unwrap();
s.wait().text("cannot be used with").until().unwrap();
}
#[test]
fn test_watch_and_select_1_conflict_errors() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(
&pt,
&["files", "--watch", "1.0", "--select-1"],
)
.start()
.unwrap();
s.wait().text("cannot be used with").until().unwrap();
}
#[test]
fn test_watch_and_take_1_conflict_errors() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(
&pt,
&["files", "--watch", "1.0", "--take-1"],
)
.start()
.unwrap();
s.wait().text("cannot be used with").until().unwrap();
}
#[test]
fn test_watch_and_take_1_fast_conflict_errors() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(
&pt,
&["files", "--watch", "1.0", "--take-1-fast"],
)
.start()
.unwrap();
s.wait().text("cannot be used with").until().unwrap();
}
#[test]
fn test_expect_with_selection() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(
&pt,
&["files", "--expect", "ctrl-c", "--input", "Cargo.toml"],
)
.start()
.unwrap();
s.wait()
.text("1 / 1")
.text("Cargo.toml")
.timeout_ms(wait_timeout_ms())
.until()
.unwrap();
s.send().key("ctrl-c").unwrap();
let output = exit_and_output(&s);
assert!(
output.contains("ctrl-c") && output.contains("Cargo.toml"),
"expected output to contain 'ctrl-c' and 'Cargo.toml', got:\n{output}"
);
}