use tempfile::TempDir;
use super::super::common::*;
#[test]
fn test_toggle_preview_keybinding() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(&pt, &["files"])
.start()
.unwrap();
s.wait().text("───╮╭───").until().unwrap();
s.send().key("ctrl-o").unwrap();
s.wait().text_absent("───╮╭───").until().unwrap();
s.send().key("ctrl-c").unwrap();
s.wait().exit_code(0).until().unwrap();
}
#[test]
fn test_toggle_remote_control_keybinding() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(&pt, &["files"])
.start()
.unwrap();
s.wait().text("── files ──").until().unwrap();
s.send().key("ctrl-t").unwrap();
s.wait().text("(1) (2) (3)").until().unwrap();
s.send().key("ctrl-c").unwrap();
s.wait().text_absent("(1) (2) (3)").until().unwrap();
s.send().key("ctrl-c").unwrap();
s.wait().exit_code(0).until().unwrap();
}
#[test]
fn test_toggle_status_bar_keybinding() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(
&pt,
&["files", "--keybindings", "ctrl-k = \"toggle_status_bar\""],
)
.start()
.unwrap();
s.wait().text("CHANNEL files").until().unwrap();
s.send().key("ctrl-k").unwrap();
s.wait().text_absent("CHANNEL files").until().unwrap();
s.send().key("ctrl-c").unwrap();
s.wait().exit_code(0).until().unwrap();
}
#[test]
fn test_toggle_help_keybinding() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(&pt, &["files"])
.start()
.unwrap();
s.wait().text("── files ──").until().unwrap();
s.send().key("ctrl-h").unwrap();
s.wait().text("───── Help ─────").until().unwrap();
s.send().key("ctrl-c").unwrap();
s.wait().exit_code(0).until().unwrap();
}
#[test]
fn test_scroll_preview_keybindings() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(
&pt,
&["files", "--input", "README.md"],
)
.start()
.unwrap();
s.wait().text("││ 1").until().unwrap();
s.send().key("pagedown").unwrap();
s.send().key("pagedown").unwrap();
s.wait().text_absent("││ 1").until().unwrap();
s.send().key("pageup").unwrap();
s.send().key("pageup").unwrap();
s.wait().text("││ 1").until().unwrap();
s.send().key("ctrl-c").unwrap();
s.wait().exit_code(0).until().unwrap();
}
#[test]
fn test_reload_source_keybinding() {
let pt = phantom();
let tmp_dir = TempDir::new().unwrap();
std::fs::write(tmp_dir.path().join("UNIQUE16CHARIDfile.txt"), "").unwrap();
let s = tv_local_config_and_cable_with_args(
&pt,
&[
"files",
"--input",
"UNIQUE16CHARID",
tmp_dir.path().to_str().unwrap(),
],
)
.start()
.unwrap();
s.wait().text("UNIQUE16CHARIDfile.txt").until().unwrap();
std::fs::write(tmp_dir.path().join("UNIQUE16CHARIDcontrol.txt"), "")
.unwrap();
s.send().key("ctrl-r").unwrap();
s.wait()
.text("UNIQUE16CHARIDcontrol.txt")
.text("UNIQUE16CHARIDfile.txt")
.until()
.unwrap();
s.send().key("ctrl-c").unwrap();
s.wait().exit_code(0).until().unwrap();
}
#[test]
fn test_cycle_sources_keybinding() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(&pt, &["files"])
.start()
.unwrap();
s.wait().text("── files ──").until().unwrap();
s.send().key("ctrl-s").unwrap();
s.send().type_text(".config").unwrap();
s.wait().text(".config/config.toml").until().unwrap();
s.send().key("ctrl-c").unwrap();
s.wait().exit_code(0).until().unwrap();
}
#[test]
fn test_toggle_preview_disabled_in_remote_control_mode() {
let pt = phantom();
let s = tv_local_config_and_cable_with_args(&pt, &["files"])
.start()
.unwrap();
s.wait()
.text("╭───────────────────────── files ──────────────────────────╮╭─")
.text("───╮╭───")
.until()
.unwrap();
s.send().key("ctrl-t").unwrap();
s.wait()
.text("(1) (2) (3)")
.text("Back to Channel:")
.until()
.unwrap();
s.send().key("ctrl-o").unwrap();
s.wait()
.text("(1) (2) (3)")
.text("Back to Channel:")
.text("╭───────────────────────── files ──────────────────────────╮╭─")
.until()
.unwrap();
s.send().key("ctrl-t").unwrap();
s.wait().text_absent("Back to Channel:").until().unwrap();
s.wait().text("───╮╭───").until().unwrap();
s.send().key("ctrl-o").unwrap();
s.wait().text_absent("───╮╭───").until().unwrap();
s.send().key("ctrl-c").unwrap();
s.wait().exit_code(0).until().unwrap();
}