use television::tui::TESTING_ENV_VAR;
use super::super::common::*;
#[test]
fn test_preview_flags_without_preview_command_in_adhoc_mode_errors() {
let mut tester = PtyTester::new();
let cmd =
tv_local_config_and_cable_with_args(&["--preview-header", "HEADER"]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains(
"preview-header requires a preview command",
);
}
#[test]
fn test_source_display_without_source_command_in_adhoc_mode_errors() {
let mut tester = PtyTester::new();
let cmd =
tv_local_config_and_cable_with_args(&["--source-display", "{upper}"]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains(
"source-display requires a source command",
);
}
#[test]
fn test_source_output_without_source_command_in_adhoc_mode_errors() {
let mut tester = PtyTester::new();
let cmd =
tv_local_config_and_cable_with_args(&["--source-output", "echo {}"]);
tester.spawn_command(cmd);
tester
.assert_raw_output_contains("source-output requires a source command");
}
#[test]
fn test_multiple_selection_flags_conflict_errors() {
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"--source-command",
"ls",
"--select-1",
"--take-1",
]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains("cannot be used with");
}
#[test]
fn test_preview_and_no_preview_conflict_errors() {
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"--source-command",
"ls",
"--no-preview",
"--preview-header",
"HEADER",
]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains("cannot be used with");
}
#[test]
fn test_channel_and_autocomplete_prompt_conflict_errors() {
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"files",
"--autocomplete-prompt",
"git log --oneline",
]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains("cannot be used with");
}
#[test]
fn test_watch_and_selection_flags_conflict_errors() {
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"--source-command",
"ls",
"--watch",
"1.0",
"--select-1",
]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains("cannot be used with");
}
#[test]
fn test_inline_and_height_conflict_errors() {
let mut tester = PtyTester::new();
let mut cmd = tv_local_config_and_cable_with_args(&[
"files", "--inline", "--height", "20",
]);
cmd.env(TESTING_ENV_VAR, "1");
tester.spawn_command(cmd);
tester.assert_raw_output_contains("cannot be used with");
}
#[test]
fn test_width_without_height_or_inline_errors() {
let mut tester = PtyTester::new();
let mut cmd =
tv_local_config_and_cable_with_args(&["files", "--width", "80"]);
cmd.env(TESTING_ENV_VAR, "1");
tester.spawn_command(cmd);
tester.assert_raw_output_contains("can only be used");
}