Expand description
Test utilities for tui-dispatch applications
This module provides helpers for testing TUI applications built with tui-dispatch:
key: CreateKeyEventfrom string (e.g.,key("ctrl+p"))key_events: Create multipleEvents from space-separated key stringTestHarness: Generic test harness with action channel and state managementActionAssertions: Fluent assertion trait for action vectors- Assertion macros for verifying emitted actions
§Example
ⓘ
use tui_dispatch::testing::{key, TestHarness, ActionAssertions};
#[derive(Clone, Debug, PartialEq)]
enum Action {
Increment,
Decrement,
}
let mut harness = TestHarness::<i32, Action>::new(0);
// Emit and check actions with fluent API
harness.emit(Action::Decrement);
harness.emit(Action::Increment);
let emitted = harness.drain_emitted();
emitted.assert_first(Action::Decrement);
emitted.assert_contains(Action::Increment);
emitted.assert_count(2);Structs§
- Render
Harness - Test harness for capturing rendered output.
- Test
Harness - Generic test harness for tui-dispatch applications.
Traits§
- Action
Assertions - Fluent assertion trait for action vectors.
- Action
Assertions Eq - Equality-based assertions for action vectors.
Functions§
- alt_key
- Create a
KeyEventfor a character with Alt modifier. - buffer_
rect_ to_ string_ plain - Convert a specific rect of a buffer to a plain string.
- buffer_
to_ string - Convert a ratatui Buffer to a string with ANSI escape codes.
- buffer_
to_ string_ plain - Convert a ratatui Buffer to a plain string (no ANSI codes).
- char_
key - Create a
KeyEventfor a character with no modifiers. - ctrl_
key - Create a
KeyEventfor a character with Ctrl modifier. - into_
event - Create an
Event<C>from aKeyEvent. - key
- Create a
KeyEventfrom a key string. - key_
event - Create an
Event<C>containing a key event from a key string. - key_
events - Create multiple
Event<C>from a space-separated key string. - keys
- Parse multiple key strings into
KeyEvents.