Recreate repository due to Git object corruption (all files preserved)
This commit is contained in:
73
tests/bindings.rs
Normal file
73
tests/bindings.rs
Normal file
@@ -0,0 +1,73 @@
|
||||
use tui_orchestrator::input::{Bindings, Key};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[allow(dead_code)]
|
||||
enum TestAction {
|
||||
Quit,
|
||||
Save,
|
||||
Open,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bindings_new() {
|
||||
let _bindings: Bindings<TestAction> = Bindings::new();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bindings_bind() {
|
||||
let mut bindings: Bindings<TestAction> = Bindings::new();
|
||||
bindings.bind(Key::char('q'), TestAction::Quit);
|
||||
assert_eq!(bindings.get(&Key::char('q')), Some(&TestAction::Quit));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bindings_get_not_found() {
|
||||
let mut bindings: Bindings<TestAction> = Bindings::new();
|
||||
bindings.bind(Key::char('q'), TestAction::Quit);
|
||||
assert_eq!(bindings.get(&Key::char('x')), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bindings_remove() {
|
||||
let mut bindings: Bindings<TestAction> = Bindings::new();
|
||||
bindings.bind(Key::char('q'), TestAction::Quit);
|
||||
bindings.remove(&Key::char('q'));
|
||||
assert_eq!(bindings.get(&Key::char('q')), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bindings_is_empty() {
|
||||
let mut bindings: Bindings<TestAction> = Bindings::new();
|
||||
assert!(bindings.is_empty());
|
||||
|
||||
bindings.bind(Key::char('q'), TestAction::Quit);
|
||||
assert!(!bindings.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bindings_len() {
|
||||
let mut bindings: Bindings<TestAction> = Bindings::new();
|
||||
assert_eq!(bindings.len(), 0);
|
||||
|
||||
bindings.bind(Key::char('q'), TestAction::Quit);
|
||||
assert_eq!(bindings.len(), 1);
|
||||
|
||||
bindings.bind(Key::char('s'), TestAction::Save);
|
||||
assert_eq!(bindings.len(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bindings_iter() {
|
||||
let mut bindings: Bindings<TestAction> = Bindings::new();
|
||||
bindings.bind(Key::char('q'), TestAction::Quit);
|
||||
bindings.bind(Key::char('s'), TestAction::Save);
|
||||
|
||||
let actions: Vec<_> = bindings.iter().map(|(_, a)| *a).collect();
|
||||
assert!(actions.contains(&TestAction::Quit));
|
||||
assert!(actions.contains(&TestAction::Save));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bindings_default() {
|
||||
let _bindings: Bindings<TestAction> = Bindings::default();
|
||||
}
|
||||
Reference in New Issue
Block a user