reorganize tests into groups

pull/2359/head
Skyler Hawthorne 3 years ago
parent 84bbe6b8f3
commit 267605d147

@ -68,7 +68,7 @@ fn setup_integration_logging() {
message message
)) ))
}) })
.level(log::LevelFilter::Debug) .level(log::LevelFilter::Info)
.chain(std::io::stdout()) .chain(std::io::stdout())
.apply(); .apply();
} }

@ -22,144 +22,7 @@ mod integration {
Ok(()) Ok(())
} }
#[tokio::test] mod auto_indent;
async fn insert_mode_cursor_position() -> anyhow::Result<()> { mod auto_pairs;
test_key_sequence_text_result( mod movement;
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(())
}
} }

@ -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(())
}

@ -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(())
}

@ -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(())
}
Loading…
Cancel
Save