Expand description
Testing utilities for RTE components.
Provides TestApp for testing components without a real terminal.
§Example
ⓘ
use rte::testing::TestApp;
use rte::prelude::*;
#[test]
fn counter_increments() {
let mut app = TestApp::new(|cx| {
let count = cx.use_state(|| 0);
let c = count.clone();
View::vstack()
.child(View::text(format!("Count: {}", count.get())))
.child(View::button().label("+").on_press(move || c.update(|n| *n + 1)).build())
.build()
});
assert!(app.find_text("Count: 0").is_some());
app.press_button("+");
assert!(app.find_text("Count: 1").is_some());
}Structs§
- TestApp
- A test harness for RTE components.