on master help sign in
reorganize tests into groups
commit267605d147587e120d765fa62333dd986a3cb5e6 authorSkyler Hawthorne <skyler@dead10ck.com> dateSun 17 Apr 2022, 00:19 (5 years ago) parent84bbe6b
5 files changed+148−141
helix-term/src/application.rs+1−1 helix-term/tests/integration.rs+3−140 helix-term/tests/integration/auto_indent.rs+24 helix-term/tests/integration/auto_pairs.rs+24 helix-term/tests/integration/movement.rs+96
helix-term/src/application.rs+1−1
@@ -68,7 +68,7 @@ fn setup_integration_logging() {
6868 message
6969 ))
7070 })
71− .level(log::LevelFilter::Debug)
71+ .level(log::LevelFilter::Info)
7272 .chain(std::io::stdout())
7373 .apply();
7474}
helix-term/tests/integration.rs+3−140
@@ -22,144 +22,7 @@ mod integration {
2222 Ok(())
2323 }
2424
25− #[tokio::test]
26− async fn insert_mode_cursor_position() -> anyhow::Result<()> {
27− test_key_sequence_text_result(
28− Args::default(),
29− Config::default(),
30− TestCase {
31− in_text: String::new(),
32− in_selection: Selection::single(0, 0),
33− in_keys: "i".into(),
34− out_text: String::new(),
35− out_selection: Selection::single(0, 0),
36− },
37− )?;
38−
39− test_key_sequence_text_result(
40− Args::default(),
41− Config::default(),
42− ("#[\n|]#", "i", "#[|\n]#"),
43− )?;
44−
45− test_key_sequence_text_result(
46− Args::default(),
47− Config::default(),
48− ("#[\n|]#", "i<esc>", "#[|\n]#"),
49− )?;
50−
51− test_key_sequence_text_result(
52− Args::default(),
53− Config::default(),
54− ("#[\n|]#", "i<esc>i", "#[|\n]#"),
55− )?;
56−
57− Ok(())
58− }
59−
60− /// Range direction is preserved when escaping insert mode to normal
61− #[tokio::test]
62− async fn insert_to_normal_mode_cursor_position() -> anyhow::Result<()> {
63− test_key_sequence_text_result(
64− Args::default(),
65− Config::default(),
66− ("#[f|]#oo\n", "vll<A-;><esc>", "#[|foo]#\n"),
67− )?;
68−
69− test_key_sequence_text_result(
70− Args::default(),
71− Config::default(),
72− (
73− indoc! {"\
74− #[f|]#oo
75− #(b|)#ar"
76− },
77− "vll<A-;><esc>",
78− indoc! {"\
79− #[|foo]#
80− #(|bar)#"
81− },
82− ),
83− )?;
84−
85− test_key_sequence_text_result(
86− Args::default(),
87− Config::default(),
88− (
89− indoc! {"\
90− #[f|]#oo
91− #(b|)#ar"
92− },
93− "a",
94− indoc! {"\
95− #[fo|]#o
96− #(ba|)#r"
97− },
98− ),
99− )?;
100−
101− test_key_sequence_text_result(
102− Args::default(),
103− Config::default(),
104− (
105− indoc! {"\
106− #[f|]#oo
107− #(b|)#ar"
108− },
109− "a<esc>",
110− indoc! {"\
111− #[f|]#oo
112− #(b|)#ar"
113− },
114− ),
115− )?;
116−
117− Ok(())
118− }
119−
120− #[tokio::test]
121− async fn auto_pairs_basic() -> anyhow::Result<()> {
122− test_key_sequence_text_result(
123− Args::default(),
124− Config::default(),
125− ("#[\n|]#", "i(<esc>", "(#[|)]#\n"),
126− )?;
127−
128− test_key_sequence_text_result(
129− Args::default(),
130− Config {
131− editor: helix_view::editor::Config {
132− auto_pairs: AutoPairConfig::Enable(false),
133− ..Default::default()
134− },
135− ..Default::default()
136− },
137− ("#[\n|]#", "i(<esc>", "(#[|\n]#"),
138− )?;
139−
140− Ok(())
141− }
142−
143− #[tokio::test]
144− async fn auto_indent_c() -> anyhow::Result<()> {
145− test_key_sequence_text_result(
146− Args {
147− files: vec![(PathBuf::from("foo.c"), Position::default())],
148− ..Default::default()
149− },
150− Config::default(),
151− // switches to append mode?
152− (
153− "void foo() {#[|}]#\n",
154− "i<ret><esc>",
155− indoc! {"\
156− void foo() {
157− #[|\n]#\
158− }
159− "},
160− ),
161− )?;
162−
163− Ok(())
164− }
25+ mod auto_indent;
26+ mod auto_pairs;
27+ mod movement;
16528}
helix-term/tests/integration/auto_indent.rsnew file+24
@@ -0,0 +1,24 @@
1+use super::*;
2+
3+#[tokio::test]
4+async fn auto_indent_c() -> anyhow::Result<()> {
5+ test_key_sequence_text_result(
6+ Args {
7+ files: vec![(PathBuf::from("foo.c"), Position::default())],
8+ ..Default::default()
9+ },
10+ Config::default(),
11+ // switches to append mode?
12+ (
13+ "void foo() {#[|}]#\n",
14+ "i<ret><esc>",
15+ indoc! {"\
16+ void foo() {
17+ #[|\n]#\
18+ }
19+ "},
20+ ),
21+ )?;
22+
23+ Ok(())
24+}
helix-term/tests/integration/auto_pairs.rsnew file+24
@@ -0,0 +1,24 @@
1+use super::*;
2+
3+#[tokio::test]
4+async fn auto_pairs_basic() -> anyhow::Result<()> {
5+ test_key_sequence_text_result(
6+ Args::default(),
7+ Config::default(),
8+ ("#[\n|]#", "i(<esc>", "(#[|)]#\n"),
9+ )?;
10+
11+ test_key_sequence_text_result(
12+ Args::default(),
13+ Config {
14+ editor: helix_view::editor::Config {
15+ auto_pairs: AutoPairConfig::Enable(false),
16+ ..Default::default()
17+ },
18+ ..Default::default()
19+ },
20+ ("#[\n|]#", "i(<esc>", "(#[|\n]#"),
21+ )?;
22+
23+ Ok(())
24+}
helix-term/tests/integration/movement.rsnew file+96
@@ -0,0 +1,96 @@
1+use super::*;
2+
3+#[tokio::test]
4+async fn insert_mode_cursor_position() -> anyhow::Result<()> {
5+ test_key_sequence_text_result(
6+ Args::default(),
7+ Config::default(),
8+ TestCase {
9+ in_text: String::new(),
10+ in_selection: Selection::single(0, 0),
11+ in_keys: "i".into(),
12+ out_text: String::new(),
13+ out_selection: Selection::single(0, 0),
14+ },
15+ )?;
16+
17+ test_key_sequence_text_result(
18+ Args::default(),
19+ Config::default(),
20+ ("#[\n|]#", "i", "#[|\n]#"),
21+ )?;
22+
23+ test_key_sequence_text_result(
24+ Args::default(),
25+ Config::default(),
26+ ("#[\n|]#", "i<esc>", "#[|\n]#"),
27+ )?;
28+
29+ test_key_sequence_text_result(
30+ Args::default(),
31+ Config::default(),
32+ ("#[\n|]#", "i<esc>i", "#[|\n]#"),
33+ )?;
34+
35+ Ok(())
36+}
37+
38+/// Range direction is preserved when escaping insert mode to normal
39+#[tokio::test]
40+async fn insert_to_normal_mode_cursor_position() -> anyhow::Result<()> {
41+ test_key_sequence_text_result(
42+ Args::default(),
43+ Config::default(),
44+ ("#[f|]#oo\n", "vll<A-;><esc>", "#[|foo]#\n"),
45+ )?;
46+
47+ test_key_sequence_text_result(
48+ Args::default(),
49+ Config::default(),
50+ (
51+ indoc! {"\
52+ #[f|]#oo
53+ #(b|)#ar"
54+ },
55+ "vll<A-;><esc>",
56+ indoc! {"\
57+ #[|foo]#
58+ #(|bar)#"
59+ },
60+ ),
61+ )?;
62+
63+ test_key_sequence_text_result(
64+ Args::default(),
65+ Config::default(),
66+ (
67+ indoc! {"\
68+ #[f|]#oo
69+ #(b|)#ar"
70+ },
71+ "a",
72+ indoc! {"\
73+ #[fo|]#o
74+ #(ba|)#r"
75+ },
76+ ),
77+ )?;
78+
79+ test_key_sequence_text_result(
80+ Args::default(),
81+ Config::default(),
82+ (
83+ indoc! {"\
84+ #[f|]#oo
85+ #(b|)#ar"
86+ },
87+ "a<esc>",
88+ indoc! {"\
89+ #[f|]#oo
90+ #(b|)#ar"
91+ },
92+ ),
93+ )?;
94+
95+ Ok(())
96+}