mirror of
https://github.com/zaphar/sheetsui.git
synced 2025-07-23 05:19:48 -04:00
wip: test coverage for handle_dialog_input
This commit is contained in:
parent
19d01f057b
commit
a65ad974ce
@ -307,19 +307,43 @@ fn test_input_navitation_shift_tab_key() {
|
|||||||
assert_eq!(col, ws.book.location.col);
|
assert_eq!(col, ws.book.location.col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! assert_help_dialog {
|
||||||
|
($exit : expr) => {{
|
||||||
|
let mut ws =
|
||||||
|
Workspace::new_empty("en", "America/New_York").expect("Failed to get empty workbook");
|
||||||
|
assert_eq!(Some(&Modality::Navigate), ws.state.modality_stack.last());
|
||||||
|
InputScript::default().char('i').run(&mut ws)
|
||||||
|
.expect("Failed to handle 'i' key");
|
||||||
|
assert_eq!(Some(&Modality::CellEdit), ws.state.modality_stack.last());
|
||||||
|
let edit_help = ws.render_help_text();
|
||||||
|
InputScript::default().alt('h').run(&mut ws)
|
||||||
|
.expect("Failed to handle 'alt-h' key event");
|
||||||
|
assert_eq!(Some(&Modality::Dialog), ws.state.modality_stack.last());
|
||||||
|
assert_eq!(edit_help, ws.state.popup);
|
||||||
|
$exit.run(&mut ws)
|
||||||
|
.expect("Failed to handle key event");
|
||||||
|
assert_eq!(Some(&Modality::CellEdit), ws.state.modality_stack.last());
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_edit_mode_help_keycode() {
|
fn test_edit_mode_help_keycode_esc() {
|
||||||
let mut ws =
|
assert_help_dialog!(InputScript::default().esc());
|
||||||
Workspace::new_empty("en", "America/New_York").expect("Failed to get empty workbook");
|
}
|
||||||
assert_eq!(Some(&Modality::Navigate), ws.state.modality_stack.last());
|
|
||||||
InputScript::default().char('i').run(&mut ws)
|
#[test]
|
||||||
.expect("Failed to handle 'i' key");
|
fn test_edit_mode_help_keycode_enter() {
|
||||||
assert_eq!(Some(&Modality::CellEdit), ws.state.modality_stack.last());
|
assert_help_dialog!(InputScript::default().enter());
|
||||||
let edit_help = ws.render_help_text();
|
}
|
||||||
InputScript::default().alt('h').run(&mut ws)
|
|
||||||
.expect("Failed to handle 'alt-h' key event");
|
#[test]
|
||||||
assert_eq!(Some(&Modality::Dialog), ws.state.modality_stack.last());
|
fn test_edit_mode_help_keycode_q() {
|
||||||
assert_eq!(edit_help, ws.state.popup);
|
assert_help_dialog!(InputScript::default().char('q'));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_edit_mode_help_keycode_alt_h() {
|
||||||
|
assert_help_dialog!(InputScript::default().alt('h'));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user