aboutsummaryrefslogtreecommitdiff
path: root/helix-term/tests/test/write.rs
diff options
context:
space:
mode:
authorSkyler Hawthorne2022-05-23 04:24:18 +0000
committerSkyler Hawthorne2022-06-19 03:57:47 +0000
commitfac36bc5eab804e823ddef01e50d1e36495c7967 (patch)
treeba695304ba5cbf6962f72c52bff8ad698b80ce9d /helix-term/tests/test/write.rs
parent7c0bca186cdacf070355c1a4ab82121d6a4d2e27 (diff)
add test for write-quit happy path
Diffstat (limited to 'helix-term/tests/test/write.rs')
-rw-r--r--helix-term/tests/test/write.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/helix-term/tests/test/write.rs b/helix-term/tests/test/write.rs
index 3d724af5..d22b3125 100644
--- a/helix-term/tests/test/write.rs
+++ b/helix-term/tests/test/write.rs
@@ -23,6 +23,7 @@ async fn test_write() -> anyhow::Result<()> {
)?,
Some("ii can eat glass, it will not hurt me<ret><esc>:w<ret>"),
None,
+ false,
)
.await?;
@@ -31,6 +32,39 @@ async fn test_write() -> anyhow::Result<()> {
let mut file_content = String::new();
file.as_file_mut().read_to_string(&mut file_content)?;
+
+ assert_eq!(
+ helpers::platform_line("i can eat glass, it will not hurt me"),
+ file_content
+ );
+
+ Ok(())
+}
+
+#[tokio::test]
+async fn test_write_quit() -> anyhow::Result<()> {
+ let mut file = tempfile::NamedTempFile::new()?;
+
+ test_key_sequence(
+ &mut Application::new(
+ Args {
+ files: vec![(file.path().to_path_buf(), Position::default())],
+ ..Default::default()
+ },
+ Config::default(),
+ )?,
+ Some("ii can eat glass, it will not hurt me<ret><esc>:wq<ret>"),
+ None,
+ true,
+ )
+ .await?;
+
+ file.as_file_mut().flush()?;
+ file.as_file_mut().sync_all()?;
+
+ let mut file_content = String::new();
+ file.as_file_mut().read_to_string(&mut file_content)?;
+
assert_eq!(
helpers::platform_line("i can eat glass, it will not hurt me"),
file_content
@@ -61,6 +95,7 @@ async fn test_write_concurrent() -> anyhow::Result<()> {
)?,
Some(&command),
None,
+ false,
)
.await?;
@@ -112,6 +147,7 @@ async fn test_write_fail_mod_flag() -> anyhow::Result<()> {
}),
),
],
+ false,
)
.await?;
@@ -149,6 +185,7 @@ async fn test_write_fail_new_path() -> anyhow::Result<()> {
}),
),
],
+ false,
)
.await?;