aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/application.rs2
-rw-r--r--helix-term/tests/integration.rs143
-rw-r--r--helix-term/tests/integration/auto_indent.rs24
-rw-r--r--helix-term/tests/integration/auto_pairs.rs24
-rw-r--r--helix-term/tests/integration/movement.rs96
5 files changed, 148 insertions, 141 deletions
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<esc>", "#[|\n]#"),
- )?;
-
- test_key_sequence_text_result(
- Args::default(),
- Config::default(),
- ("#[\n|]#", "i<esc>i", "#[|\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<A-;><esc>", "#[|foo]#\n"),
- )?;
-
- test_key_sequence_text_result(
- Args::default(),
- Config::default(),
- (
- indoc! {"\
- #[f|]#oo
- #(b|)#ar"
- },
- "vll<A-;><esc>",
- 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<esc>",
- 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(<esc>", "(#[|)]#\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(<esc>", "(#[|\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<ret><esc>",
- 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<ret><esc>",
+ 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(<esc>", "(#[|)]#\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(<esc>", "(#[|\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<esc>", "#[|\n]#"),
+ )?;
+
+ test_key_sequence_text_result(
+ Args::default(),
+ Config::default(),
+ ("#[\n|]#", "i<esc>i", "#[|\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<A-;><esc>", "#[|foo]#\n"),
+ )?;
+
+ test_key_sequence_text_result(
+ Args::default(),
+ Config::default(),
+ (
+ indoc! {"\
+ #[f|]#oo
+ #(b|)#ar"
+ },
+ "vll<A-;><esc>",
+ 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<esc>",
+ indoc! {"\
+ #[f|]#oo
+ #(b|)#ar"
+ },
+ ),
+ )?;
+
+ Ok(())
+}