Lines
99.12 %
Functions
100 %
Branches
//! Help is the focused chain's bindings, then the `:` commands.
use super::help_lines;
use crate::app::App;
use crate::form::Form;
use crate::modal::Modal;
use crate::view::Tab;
fn help(app: &App) -> String {
help_lines(app).join("\n")
}
fn line_with(app: &App, keys: &str, name: &str, text: &str) -> bool {
let wanted = format!(" {keys:<16}{name:<26}{text}");
help_lines(app).contains(&wanted)
#[test]
fn help_lists_the_keys_of_the_preset_with_their_descriptions() {
let cua = crate::test_support::app();
assert!(line_with(&cua, "F1", "open-help", "Show the key help"));
assert!(line_with(
&cua,
"M-x",
"quit",
"Ask, then leave the application"
));
"F10, M-m",
"open-menu",
"Open the menu bar"
let emacs = crate::test_support::emacs_app();
&emacs,
"q",
"close-or-quit",
"Close the front window, or ask to quit when none is open"
assert!(!line_with(&emacs, "F1", "open-help", "Show the key help"));
assert!(line_with(&emacs, "F10", "open-menu", "Open the menu bar"));
fn a_binding_of_one_action_gathers_its_chords_on_a_row() {
let mut app = crate::test_support::app();
app.switch_tab(Tab::Accounts);
&app,
"Down, j",
"next-row",
"Select the next row"
fn a_payload_action_names_its_argument() {
let app = crate::test_support::app();
"2",
"select-tab transactions",
"Go to a tab"
fn each_scope_of_the_chain_is_a_titled_section() {
app.switch_tab(Tab::Transactions);
let text = help(&app);
let order: Vec<_> = ["Transactions\n", "Lists\n", "Views\n", "Everywhere\n"]
.iter()
.map(|title| text.find(title))
.collect();
assert!(order.iter().all(Option::is_some), "{text}");
assert!(order.windows(2).all(|pair| pair[0] < pair[1]), "{text}");
fn help_describes_the_context_it_is_opened_in() {
app.overlays.push(Modal::Form(Form::config_set()));
assert!(text.contains("Forms and dialogs\n"), "{text}");
"M-o, F2",
"submit",
"Submit the form or the command line"
assert!(!text.contains("Lists\n"), "{text}");
fn help_follows_an_override() {
app.keys = match app.keys.overridden("list: F9 = new-row; list: c = none") {
Ok(keys) => keys,
Err(err) => panic!("the override parses: {err}"),
};
"Insert, F9",
"new-row",
"Create a row in the active tab"
assert!(!help(&app).contains(" n "), "{}", help(&app));
fn the_commands_follow_the_keys_and_come_from_the_command_tree() {
let lines = help_lines(&app);
assert!(
lines.contains(&"Commands, after :".to_string()),
"{lines:?}"
);
assert!(lines.contains(&" version".to_string()), "{lines:?}");
lines
.any(|line| line.starts_with(" account list|balance")),
fn without_a_command_line_key_the_commands_have_a_plain_title() {
assert!(help_lines(&app).contains(&"Commands".to_string()));
fn help_lists_only_keys_that_act_in_the_context() {
assert!(!text.contains("delete-row"), "{text}");
for hidden in ["M-x", "C-b", "C-t"] {
assert!(!text.contains(hidden), "{hidden}: {text}");