adding tests

This commit is contained in:
Théo Daron 2024-07-30 23:03:22 +02:00
parent 0e6144567c
commit c2172847b2

View File

@ -1,5 +1,5 @@
use super::*; use super::*;
use std::borrow::Cow;
#[tokio::test(flavor = "multi_thread")] #[tokio::test(flavor = "multi_thread")]
async fn test_variable_expansion() -> anyhow::Result<()> { async fn test_variable_expansion() -> anyhow::Result<()> {
{ {
@ -19,8 +19,6 @@ async fn test_variable_expansion() -> anyhow::Result<()> {
.await?; .await?;
let mut app = AppBuilder::new().build()?; let mut app = AppBuilder::new().build()?;
let mut app = AppBuilder::new().build()?;
test_key_sequence( test_key_sequence(
&mut app, &mut app,
Some("<esc>:echo %{basename}<ret>"), Some("<esc>:echo %{basename}<ret>"),
@ -128,6 +126,57 @@ async fn test_variable_expansion() -> anyhow::Result<()> {
false, false,
) )
.await?; .await?;
let mut app = AppBuilder::new().build()?;
test_key_sequence(
&mut app,
Some("<esc>:echo %sh{echo %{filename}}<ret>"),
Some(&|app| {
assert_eq!(
app.editor.get_status().unwrap().0,
helix_view::document::SCRATCH_BUFFER_NAME
);
}),
false,
)
.await?;
let mut app = AppBuilder::new().build()?;
test_key_sequence(
&mut app,
Some("<esc>:echo %sh{echo %{filename} %{linenumber}}<ret>"),
Some(&|app| {
assert_eq!(
app.editor.get_status().unwrap().0,
&Cow::from(format!(
"{} {}",
helix_view::document::SCRATCH_BUFFER_NAME,
1
))
);
}),
false,
)
.await?;
let mut app = AppBuilder::new().build()?;
test_key_sequence(
&mut app,
Some("<esc>:echo %sh{echo %{filename} %sh{echo %{filename}}}<ret>"),
Some(&|app| {
assert_eq!(
app.editor.get_status().unwrap().0,
&Cow::from(format!(
"{} {}",
helix_view::document::SCRATCH_BUFFER_NAME,
helix_view::document::SCRATCH_BUFFER_NAME
))
);
}),
false,
)
.await?;
} }
Ok(()) Ok(())