diff options
author | Blaž Hrastnik | 2021-10-26 09:03:03 +0000 |
---|---|---|
committer | Skyler Hawthorne | 2022-06-19 03:54:03 +0000 |
commit | 308cab3e5cd5e8d5a8c37498e725f51ab101a908 (patch) | |
tree | f6725f2e22a42ee22dc404ccecf0f8272194dd52 | |
parent | adb6cd537628308a23fe6ea86f1c7b419c4d8c68 (diff) |
Integration testing harness
-rw-r--r-- | helix-term/src/application.rs | 4 | ||||
-rw-r--r-- | helix-term/tests/integration.rs | 24 |
2 files changed, 26 insertions, 2 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 075b9c35..09b7836f 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -41,7 +41,7 @@ type Signals = futures_util::stream::Empty<()>; pub struct Application { compositor: Compositor, - editor: Editor, + pub editor: Editor, config: Arc<ArcSwap<Config>>, @@ -193,7 +193,7 @@ impl Application { scroll: None, }; - self.compositor.render(&mut cx); + // self.compositor.render(&mut cx); } pub async fn event_loop(&mut self) { diff --git a/helix-term/tests/integration.rs b/helix-term/tests/integration.rs new file mode 100644 index 00000000..1ef618f7 --- /dev/null +++ b/helix-term/tests/integration.rs @@ -0,0 +1,24 @@ +use helix_term::{application::Application, args::Args, config::Config}; +use helix_view::current; + +use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers}; + +#[tokio::test] +async fn it_works() { + let args = Args::default(); + let config = Config::default(); + let mut app = Application::new(args, config).unwrap(); + + let inputs = &['i', 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']; + + for input in inputs { + // TODO: use input.parse::<KeyEvent> + app.handle_terminal_events(Ok(Event::Key(KeyEvent { + code: KeyCode::Char(*input), + modifiers: KeyModifiers::NONE, + }))); + } + + let (_, doc) = current!(app.editor); + assert_eq!(doc.text(), "hello world\n"); +} |