tests are passing

This commit is contained in:
filipriec_vm
2026-01-11 10:50:23 +01:00
parent d41182b13b
commit 0926bbee46
2 changed files with 18 additions and 3 deletions

View File

@@ -1,4 +1,6 @@
use tui_orchestrator::input::{Bindings, Key}; extern crate alloc;
use tui_orchestrator::input::{Action, Bindings, Key};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[allow(dead_code)] #[allow(dead_code)]
@@ -8,6 +10,8 @@ enum TestAction {
Open, Open,
} }
impl Action for TestAction {}
#[test] #[test]
fn test_bindings_new() { fn test_bindings_new() {
let _bindings: Bindings<TestAction> = Bindings::new(); let _bindings: Bindings<TestAction> = Bindings::new();

View File

@@ -51,11 +51,22 @@ impl Component for TestComponent {
self.field_b.clear(); self.field_b.clear();
Ok(()) Ok(())
} }
fn handle_text(
&mut self,
focus: &Self::Focus,
ch: char,
) -> Result<Option<Self::Event>, tui_orchestrator::component::error::ComponentError> {
match focus {
Self::Focus::FieldA | Self::Focus::FieldB => Ok(Some(Self::Event::TextTyped(ch))),
_ => Ok(None),
}
}
} }
#[test] #[test]
fn test_component_targets() { fn test_component_targets() {
let mut component = TestComponent { let component = TestComponent {
field_a: alloc::string::String::new(), field_a: alloc::string::String::new(),
field_b: alloc::string::String::new(), field_b: alloc::string::String::new(),
}; };
@@ -109,7 +120,7 @@ fn test_component_on_enter_clears() {
#[test] #[test]
fn test_component_defaults() { fn test_component_defaults() {
let component = TestComponent { let mut component = TestComponent {
field_a: alloc::string::String::new(), field_a: alloc::string::String::new(),
field_b: alloc::string::String::new(), field_b: alloc::string::String::new(),
}; };