diff options
author | Skyler Hawthorne | 2022-11-11 04:58:03 +0000 |
---|---|---|
committer | Michael Davis | 2023-03-20 23:34:40 +0000 |
commit | 4bdeb9927b5aa0fb71484faae8f3aa9c5ce67381 (patch) | |
tree | 6c348fd5ff2d937560df81ced6572cfa8b14050c /helix-term/tests/test | |
parent | d3b051d28ea62c313fc72583d04f2a897e8d6f40 (diff) |
migrate test_with_config to use AppBuilder
Diffstat (limited to 'helix-term/tests/test')
-rw-r--r-- | helix-term/tests/test/auto_indent.rs | 7 | ||||
-rw-r--r-- | helix-term/tests/test/auto_pairs.rs | 14 | ||||
-rw-r--r-- | helix-term/tests/test/helpers.rs | 17 | ||||
-rw-r--r-- | helix-term/tests/test/movement.rs | 28 |
4 files changed, 13 insertions, 53 deletions
diff --git a/helix-term/tests/test/auto_indent.rs b/helix-term/tests/test/auto_indent.rs index e626acad..5132d44d 100644 --- a/helix-term/tests/test/auto_indent.rs +++ b/helix-term/tests/test/auto_indent.rs @@ -3,12 +3,7 @@ use super::*; #[tokio::test(flavor = "multi_thread")] async fn auto_indent_c() -> anyhow::Result<()> { test_with_config( - Args { - files: vec![(PathBuf::from("foo.c"), Position::default())], - ..Default::default() - }, - helpers::test_config(), - helpers::test_syntax_conf(None), + AppBuilder::new().with_file("foo.c", None), // switches to append mode? ( helpers::platform_line("void foo() {#[|}]#"), diff --git a/helix-term/tests/test/auto_pairs.rs b/helix-term/tests/test/auto_pairs.rs index e18c7119..e10e0840 100644 --- a/helix-term/tests/test/auto_pairs.rs +++ b/helix-term/tests/test/auto_pairs.rs @@ -41,9 +41,7 @@ async fn insert_configured_multi_byte_chars() -> anyhow::Result<()> { for (open, close) in pairs.iter() { test_with_config( - Args::default(), - config.clone(), - helpers::test_syntax_conf(None), + AppBuilder::new().with_config(config.clone()), ( format!("#[{}|]#", LINE_END), format!("i{}", open), @@ -53,9 +51,7 @@ async fn insert_configured_multi_byte_chars() -> anyhow::Result<()> { .await?; test_with_config( - Args::default(), - config.clone(), - helpers::test_syntax_conf(None), + AppBuilder::new().with_config(config.clone()), ( format!("{}#[{}|]#{}", open, close, LINE_END), format!("i{}", close), @@ -170,15 +166,13 @@ async fn insert_before_eol() -> anyhow::Result<()> { async fn insert_auto_pairs_disabled() -> anyhow::Result<()> { for pair in DEFAULT_PAIRS { test_with_config( - Args::default(), - Config { + AppBuilder::new().with_config(Config { editor: helix_view::editor::Config { auto_pairs: AutoPairConfig::Enable(false), ..Default::default() }, ..Default::default() - }, - helpers::test_syntax_conf(None), + }), ( format!("#[{}|]#", LINE_END), format!("i{}", pair.0), diff --git a/helix-term/tests/test/helpers.rs b/helix-term/tests/test/helpers.rs index 77332fa5..ccd07bfa 100644 --- a/helix-term/tests/test/helpers.rs +++ b/helix-term/tests/test/helpers.rs @@ -178,14 +178,11 @@ pub fn test_syntax_conf(overrides: Option<String>) -> helix_core::syntax::Config /// document, selection, and sequence of key presses, and you just /// want to verify the resulting document and selection. pub async fn test_with_config<T: Into<TestCase>>( - args: Args, - mut config: Config, - syn_conf: helix_core::syntax::Configuration, + app_builder: AppBuilder, test_case: T, ) -> anyhow::Result<()> { let test_case = test_case.into(); - config = helix_term::keymap::merge_keys(config); - let app = Application::new(args, config, syn_conf)?; + let app = app_builder.build()?; test_key_sequence_with_input_text( Some(app), @@ -206,13 +203,7 @@ pub async fn test_with_config<T: Into<TestCase>>( } pub async fn test<T: Into<TestCase>>(test_case: T) -> anyhow::Result<()> { - test_with_config( - Args::default(), - test_config(), - test_syntax_conf(None), - test_case, - ) - .await + test_with_config(AppBuilder::default(), test_case).await } pub fn temp_file_with_contents<S: AsRef<str>>( @@ -310,7 +301,7 @@ impl AppBuilder { // Remove this attribute once `with_config` is used in a test: #[allow(dead_code)] pub fn with_config(mut self, config: Config) -> Self { - self.config = config; + self.config = helix_term::keymap::merge_keys(config); self } diff --git a/helix-term/tests/test/movement.rs b/helix-term/tests/test/movement.rs index 6cc89021..e10ec6f5 100644 --- a/helix-term/tests/test/movement.rs +++ b/helix-term/tests/test/movement.rs @@ -413,12 +413,7 @@ async fn cursor_position_append_eof() -> anyhow::Result<()> { #[tokio::test(flavor = "multi_thread")] async fn select_mode_tree_sitter_next_function_is_union_of_objects() -> anyhow::Result<()> { test_with_config( - Args { - files: vec![(PathBuf::from("foo.rs"), Position::default())], - ..Default::default() - }, - Config::default(), - helpers::test_syntax_conf(None), + AppBuilder::new().with_file("foo.rs", None), ( helpers::platform_line(indoc! {"\ #[/|]#// Increments @@ -443,12 +438,7 @@ async fn select_mode_tree_sitter_next_function_is_union_of_objects() -> anyhow:: #[tokio::test(flavor = "multi_thread")] async fn select_mode_tree_sitter_prev_function_unselects_object() -> anyhow::Result<()> { test_with_config( - Args { - files: vec![(PathBuf::from("foo.rs"), Position::default())], - ..Default::default() - }, - Config::default(), - helpers::test_syntax_conf(None), + AppBuilder::new().with_file("foo.rs", None), ( helpers::platform_line(indoc! {"\ /// Increments @@ -474,12 +464,7 @@ async fn select_mode_tree_sitter_prev_function_unselects_object() -> anyhow::Res async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> anyhow::Result<()> { // Note: the anchor stays put and the head moves back. test_with_config( - Args { - files: vec![(PathBuf::from("foo.rs"), Position::default())], - ..Default::default() - }, - Config::default(), - helpers::test_syntax_conf(None), + AppBuilder::new().with_file("foo.rs", None), ( helpers::platform_line(indoc! {"\ /// Increments @@ -503,12 +488,7 @@ async fn select_mode_tree_sitter_prev_function_goes_backwards_to_object() -> any .await?; test_with_config( - Args { - files: vec![(PathBuf::from("foo.rs"), Position::default())], - ..Default::default() - }, - Config::default(), - helpers::test_syntax_conf(None), + AppBuilder::new().with_file("foo.rs", None), ( helpers::platform_line(indoc! {"\ /// Increments |