Skip to main content

Module testing

Module testing 

Source
Expand description

Testing utilities for Telex components.

Provides TestApp for testing components without a real terminal.

§Example

use telex::testing::TestApp;
use telex::prelude::*;

#[test]
fn counter_increments() {
    let mut app = TestApp::new(|cx| {
        let count = state!(cx, || 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§

StreamTestEventSource
A test event source that lets real time pass with no user input.
TestApp
A test harness for Telex components.
TestEventSource
A test event source that replays a scripted sequence of events.