add tests

This commit is contained in:
Evan Almloff committed 2022-06-13 19:55:57 -05:00
1 parent d9e14db434
commit 3dc68ffd76
3 files changed
+363 -3

No files matched your search

+9 -3
View File
@@ -52,6 +52,12 @@ impl TuiContext {
pub fn quit(&self) {
self.tx.unbounded_send(InputEvent::Close).unwrap();
}
pub fn inject_event(&self, event: crossterm::event::Event) {
self.tx
.unbounded_send(InputEvent::UserInput(event))
.unwrap();
}
}
pub fn launch(app: Component<()>) {
@@ -71,7 +77,6 @@ pub fn launch_cfg(app: Component<()>, cfg: Config) {
let tick_rate = Duration::from_millis(1000);
loop {
if crossterm::event::poll(tick_rate).unwrap() {
// if crossterm::event::poll(timeout).unwrap() {
let evt = crossterm::event::read().unwrap();
if event_tx.unbounded_send(InputEvent::UserInput(evt)).is_err() {
break;
@@ -180,8 +185,8 @@ fn render_vdom(
Rect {
x: 0,
y: 0,
width: 300,
height: 300,
width: 100,
height: 100,
},
&mut taffy.borrow_mut(),
&rdom,
@@ -251,6 +256,7 @@ fn render_vdom(
})
}
#[derive(Debug)]
enum InputEvent {
UserInput(TermEvent),
Close,