use super::super::*;
fn shifted(key: Key) -> Option<KeyAction> {
keymap(key, Mods::CommandShift, Held::TextBox)
}
#[test]
fn command_shift_digits_focus_the_center_tabs() {
let want = [
(1, CenterTab::Conversation),
(2, CenterTab::Config),
(3, CenterTab::Login),
(4, CenterTab::Search),
];
for (n, tab) in want {
assert_eq!(
shifted(Key::Digit(n)),
Some(KeyAction::Center(tab)),
"Ctrl+Shift+{n} focuses {tab:?} from inside the composer"
);
assert_eq!(CenterTab::from_digit(n), Some(tab));
assert_eq!(
keymap(Key::Digit(n), Mods::Command, Held::Nothing),
InspectorTab::from_digit(n).map(KeyAction::Tab),
"the unshifted digit still names the altitude-2 tab"
);
}
for n in [0, 5, 6, 9] {
assert_eq!(
CenterTab::from_digit(n),
None,
"digit {n} names no center tab"
);
assert_eq!(
shifted(Key::Digit(n)),
None,
"Ctrl+Shift+{n} focuses nothing"
);
}
assert_eq!(
keymap(Key::Digit(2), Mods::Bare, Held::Nothing),
Some(KeyAction::Tab(InspectorTab::Steps))
);
}
#[test]
fn the_center_strip_lists_four_tabs_in_order_and_states_each() {
let all = CenterTab::all();
assert_eq!(all.len(), 4);
assert_eq!(
all[0],
CenterTab::default(),
"the conversation is where the center rests"
);
let labels: Vec<&str> = all.iter().map(|t| t.label()).collect();
assert_eq!(labels, vec!["Conversation", "Config", "Login", "Search"]);
for tab in all {
assert!(
tab.hint().len() > 20,
"{tab:?} says nothing useful on hover"
);
let hover = tab.focus_hover();
assert!(hover.starts_with(tab.hint()), "{tab:?} hides what it shows");
assert!(
hover.contains(&format!("Ctrl+Shift+{}", tab.digit())),
"{tab:?} hides its own combo: {hover}"
);
}
for (i, tab) in all.into_iter().enumerate() {
assert_eq!(CenterTab::from_digit(i as u8 + 1), Some(tab));
}
}