Skip to content

Commit

Permalink
Make keybind test more relatable
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Jan 29, 2025
1 parent 9fe3599 commit 5f3ae6b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions widget/src/keybind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,18 @@ mod test {

#[test]
fn it_triggers_a_click() {
#[derive(Debug, Clone, PartialEq, Eq)]
enum Message {
Save,
}

let keybind: Keybind<'_, _, crate::Theme> =
Keybind::new('s', button("Test!").on_press(42));
Keybind::new('s', button("Save").on_press(Message::Save));

let mut ui = simulator(keybind);
let status = ui.tap_hotkey('s');

assert_eq!(status, event::Status::Captured);
assert_eq!(ui.into_messages().collect::<Vec<_>>(), vec![42]);
assert_eq!(ui.into_messages().collect::<Vec<_>>(), vec![Message::Save]);
}
}

0 comments on commit 5f3ae6b

Please sign in to comment.