Lines
100 %
Functions
Branches
//! `acts` is the one answer to "does this intent do anything here".
use super::*;
use crate::form::Form;
use crate::test_support::app;
fn app_on(tab: Tab) -> App {
let mut app = app();
app.switch_tab(tab);
app
}
#[test]
fn new_and_delete_row_act_only_on_the_tabs_that_handle_them() {
for (tab, new, delete) in [
(Tab::Accounts, true, false),
(Tab::Transactions, true, true),
(Tab::Commodities, true, false),
(Tab::Config, true, false),
(Tab::Tags, true, true),
] {
let app = app_on(tab);
assert_eq!(acts(&app, Intent::NewRow), new, "{tab:?} new");
assert_eq!(acts(&app, Intent::DeleteRow), delete, "{tab:?} delete");
assert!(!acts(&app_on(Tab::SshKeys), Intent::EditRow));
fn quit_does_not_act_under_a_modal() {
assert!(acts(&app, Intent::Quit));
app.overlays.push(Modal::Form(Form::config_set()));
assert!(!acts(&app, Intent::Quit));
fn help_acts_with_a_help_window_or_a_form_open() {
assert!(acts(&app, Intent::OpenHelp));
apply(&mut app, Intent::OpenHelp);
fn form_keys_act_only_where_the_focused_field_takes_them() {
assert!(!acts(&app, Intent::ToggleSplitTags));
assert!(!acts(&app, Intent::OpenFilterBuilder));
app.overlays.pop();
app.overlays.push(Modal::Form(Form::template_create()));
assert!(acts(&app, Intent::ToggleSplitTags));
fn an_intent_with_no_rule_acts() {
assert!(acts(&app(), Intent::MoveLeft));