From 267605d147587e120d765fa62333dd986a3cb5e6 Mon Sep 17 00:00:00 2001 From: Skyler Hawthorne Date: Sun, 17 Apr 2022 00:19:22 -0400 Subject: [PATCH] reorganize tests into groups --- helix-term/src/application.rs | 2 +- helix-term/tests/integration.rs | 143 +------------------- helix-term/tests/integration/auto_indent.rs | 24 ++++ helix-term/tests/integration/auto_pairs.rs | 24 ++++ helix-term/tests/integration/movement.rs | 96 +++++++++++++ 5 files changed, 148 insertions(+), 141 deletions(-) create mode 100644 helix-term/tests/integration/auto_indent.rs create mode 100644 helix-term/tests/integration/auto_pairs.rs create mode 100644 helix-term/tests/integration/movement.rs diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 146194bf..44025ea0 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -68,7 +68,7 @@ fn setup_integration_logging() { message )) }) - .level(log::LevelFilter::Debug) + .level(log::LevelFilter::Info) .chain(std::io::stdout()) .apply(); } diff --git a/helix-term/tests/integration.rs b/helix-term/tests/integration.rs index a32eebf5..a388cf6b 100644 --- a/helix-term/tests/integration.rs +++ b/helix-term/tests/integration.rs @@ -22,144 +22,7 @@ mod integration { Ok(()) } - #[tokio::test] - async fn insert_mode_cursor_position() -> anyhow::Result<()> { - test_key_sequence_text_result( - Args::default(), - Config::default(), - TestCase { - in_text: String::new(), - in_selection: Selection::single(0, 0), - in_keys: "i".into(), - out_text: String::new(), - out_selection: Selection::single(0, 0), - }, - )?; - - test_key_sequence_text_result( - Args::default(), - Config::default(), - ("#[\n|]#", "i", "#[|\n]#"), - )?; - - test_key_sequence_text_result( - Args::default(), - Config::default(), - ("#[\n|]#", "i", "#[|\n]#"), - )?; - - test_key_sequence_text_result( - Args::default(), - Config::default(), - ("#[\n|]#", "ii", "#[|\n]#"), - )?; - - Ok(()) - } - - /// Range direction is preserved when escaping insert mode to normal - #[tokio::test] - async fn insert_to_normal_mode_cursor_position() -> anyhow::Result<()> { - test_key_sequence_text_result( - Args::default(), - Config::default(), - ("#[f|]#oo\n", "vll", "#[|foo]#\n"), - )?; - - test_key_sequence_text_result( - Args::default(), - Config::default(), - ( - indoc! {"\ - #[f|]#oo - #(b|)#ar" - }, - "vll", - indoc! {"\ - #[|foo]# - #(|bar)#" - }, - ), - )?; - - test_key_sequence_text_result( - Args::default(), - Config::default(), - ( - indoc! {"\ - #[f|]#oo - #(b|)#ar" - }, - "a", - indoc! {"\ - #[fo|]#o - #(ba|)#r" - }, - ), - )?; - - test_key_sequence_text_result( - Args::default(), - Config::default(), - ( - indoc! {"\ - #[f|]#oo - #(b|)#ar" - }, - "a", - indoc! {"\ - #[f|]#oo - #(b|)#ar" - }, - ), - )?; - - Ok(()) - } - - #[tokio::test] - async fn auto_pairs_basic() -> anyhow::Result<()> { - test_key_sequence_text_result( - Args::default(), - Config::default(), - ("#[\n|]#", "i(", "(#[|)]#\n"), - )?; - - test_key_sequence_text_result( - Args::default(), - Config { - editor: helix_view::editor::Config { - auto_pairs: AutoPairConfig::Enable(false), - ..Default::default() - }, - ..Default::default() - }, - ("#[\n|]#", "i(", "(#[|\n]#"), - )?; - - Ok(()) - } - - #[tokio::test] - async fn auto_indent_c() -> anyhow::Result<()> { - test_key_sequence_text_result( - Args { - files: vec![(PathBuf::from("foo.c"), Position::default())], - ..Default::default() - }, - Config::default(), - // switches to append mode? - ( - "void foo() {#[|}]#\n", - "i", - indoc! {"\ - void foo() { - #[|\n]#\ - } - "}, - ), - )?; - - Ok(()) - } + mod auto_indent; + mod auto_pairs; + mod movement; } diff --git a/helix-term/tests/integration/auto_indent.rs b/helix-term/tests/integration/auto_indent.rs new file mode 100644 index 00000000..18138cca --- /dev/null +++ b/helix-term/tests/integration/auto_indent.rs @@ -0,0 +1,24 @@ +use super::*; + +#[tokio::test] +async fn auto_indent_c() -> anyhow::Result<()> { + test_key_sequence_text_result( + Args { + files: vec![(PathBuf::from("foo.c"), Position::default())], + ..Default::default() + }, + Config::default(), + // switches to append mode? + ( + "void foo() {#[|}]#\n", + "i", + indoc! {"\ + void foo() { + #[|\n]#\ + } + "}, + ), + )?; + + Ok(()) +} diff --git a/helix-term/tests/integration/auto_pairs.rs b/helix-term/tests/integration/auto_pairs.rs new file mode 100644 index 00000000..4da44d45 --- /dev/null +++ b/helix-term/tests/integration/auto_pairs.rs @@ -0,0 +1,24 @@ +use super::*; + +#[tokio::test] +async fn auto_pairs_basic() -> anyhow::Result<()> { + test_key_sequence_text_result( + Args::default(), + Config::default(), + ("#[\n|]#", "i(", "(#[|)]#\n"), + )?; + + test_key_sequence_text_result( + Args::default(), + Config { + editor: helix_view::editor::Config { + auto_pairs: AutoPairConfig::Enable(false), + ..Default::default() + }, + ..Default::default() + }, + ("#[\n|]#", "i(", "(#[|\n]#"), + )?; + + Ok(()) +} diff --git a/helix-term/tests/integration/movement.rs b/helix-term/tests/integration/movement.rs new file mode 100644 index 00000000..d2e01e71 --- /dev/null +++ b/helix-term/tests/integration/movement.rs @@ -0,0 +1,96 @@ +use super::*; + +#[tokio::test] +async fn insert_mode_cursor_position() -> anyhow::Result<()> { + test_key_sequence_text_result( + Args::default(), + Config::default(), + TestCase { + in_text: String::new(), + in_selection: Selection::single(0, 0), + in_keys: "i".into(), + out_text: String::new(), + out_selection: Selection::single(0, 0), + }, + )?; + + test_key_sequence_text_result( + Args::default(), + Config::default(), + ("#[\n|]#", "i", "#[|\n]#"), + )?; + + test_key_sequence_text_result( + Args::default(), + Config::default(), + ("#[\n|]#", "i", "#[|\n]#"), + )?; + + test_key_sequence_text_result( + Args::default(), + Config::default(), + ("#[\n|]#", "ii", "#[|\n]#"), + )?; + + Ok(()) +} + +/// Range direction is preserved when escaping insert mode to normal +#[tokio::test] +async fn insert_to_normal_mode_cursor_position() -> anyhow::Result<()> { + test_key_sequence_text_result( + Args::default(), + Config::default(), + ("#[f|]#oo\n", "vll", "#[|foo]#\n"), + )?; + + test_key_sequence_text_result( + Args::default(), + Config::default(), + ( + indoc! {"\ + #[f|]#oo + #(b|)#ar" + }, + "vll", + indoc! {"\ + #[|foo]# + #(|bar)#" + }, + ), + )?; + + test_key_sequence_text_result( + Args::default(), + Config::default(), + ( + indoc! {"\ + #[f|]#oo + #(b|)#ar" + }, + "a", + indoc! {"\ + #[fo|]#o + #(ba|)#r" + }, + ), + )?; + + test_key_sequence_text_result( + Args::default(), + Config::default(), + ( + indoc! {"\ + #[f|]#oo + #(b|)#ar" + }, + "a", + indoc! {"\ + #[f|]#oo + #(b|)#ar" + }, + ), + )?; + + Ok(()) +}