on master help sign in
Integration testing harness
308cab3Blaž Hrastnik
helix-term/src/application.rs+2−2
@@ -41,7 +41,7 @@ type Signals = futures_util::stream::Empty<()>;
41
41
42pub struct Application {
42pub struct Application {
43 compositor: Compositor,
43 compositor: Compositor,
44− editor: Editor,
44+ pub editor: Editor,
45
45
46 config: Arc<ArcSwap<Config>>,
46 config: Arc<ArcSwap<Config>>,
47
47
@@ -193,7 +193,7 @@ impl Application {
193 scroll: None,
193 scroll: None,
194 };
194 };
195
195
196− self.compositor.render(&mut cx);
196+ // self.compositor.render(&mut cx);
197 }
197 }
198
198
199 pub async fn event_loop(&mut self) {
199 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+}