on master help sign in
Integration testing harness
commit308cab3e5cd5e8d5a8c37498e725f51ab101a908 authorBlaž Hrastnik <blaz@mxxn.io> dateTue 26 Oct 2021, 18:03 (5 years ago) parentadb6cd5
2 files changed+26−2
helix-term/src/application.rs+2−2 helix-term/tests/integration.rs+24
helix-term/src/application.rs+2−2
@@ -41,7 +41,7 @@ type Signals = futures_util::stream::Empty<()>;
4141
4242pub struct Application {
4343 compositor: Compositor,
44− editor: Editor,
44+ pub editor: Editor,
4545
4646 config: Arc<ArcSwap<Config>>,
4747
@@ -193,7 +193,7 @@ impl Application {
193193 scroll: None,
194194 };
195195
196− self.compositor.render(&mut cx);
196+ // self.compositor.render(&mut cx);
197197 }
198198
199199 pub async fn event_loop(&mut self) {
helix-term/tests/integration.rsnew file+24
@@ -0,0 +1,24 @@
1+use helix_term::{application::Application, args::Args, config::Config};
2+use helix_view::current;
3+
4+use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
5+
6+#[tokio::test]
7+async fn it_works() {
8+ let args = Args::default();
9+ let config = Config::default();
10+ let mut app = Application::new(args, config).unwrap();
11+
12+ let inputs = &['i', 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'];
13+
14+ for input in inputs {
15+ // TODO: use input.parse::<KeyEvent>
16+ app.handle_terminal_events(Ok(Event::Key(KeyEvent {
17+ code: KeyCode::Char(*input),
18+ modifiers: KeyModifiers::NONE,
19+ })));
20+ }
21+
22+ let (_, doc) = current!(app.editor);
23+ assert_eq!(doc.text(), "hello world\n");
24+}