Add unit tests for paste_all_selections_(before|after).

pull/13698/head
Andrew Browne 2025-06-05 21:43:39 -07:00
parent e9975c1939
commit 3458b7b037
2 changed files with 60 additions and 0 deletions

View File

@ -4,6 +4,7 @@ use super::*;
mod insert; mod insert;
mod movement; mod movement;
mod paste_all_selections;
mod write; mod write;
#[tokio::test(flavor = "multi_thread")] #[tokio::test(flavor = "multi_thread")]

View File

@ -0,0 +1,59 @@
use super::*;
use helix_core::hashmap;
use helix_term::keymap;
use helix_view::document::Mode;
#[tokio::test(flavor = "multi_thread")]
async fn paste_all_selections() -> anyhow::Result<()> {
let mut config = Config::default();
config.keys.insert(
Mode::Normal,
keymap!({"Normal Mode"
"A-P" => paste_all_selections_before,
"A-p" => paste_all_selections_after,
}),
);
// Test paste_all_selections_before
// Selection direction matches paste target selections.
test_with_config(
AppBuilder::new().with_config(config.clone()),
(
indoc! {"\
#(|one)#_cat
#(|two)#_dog
#[|three]#_cow
"},
"y<A-P>",
indoc! {"\
#(|one)##(|two)##(|three)#one_cat
#(|one)##(|two)##(|three)#two_dog
#(|one)##(|two)##[|three]#three_cow
"},
),
)
.await?;
// Test paste_all_selections_after
// Primary selection is last selection pasted for previous primary.
test_with_config(
AppBuilder::new().with_config(config.clone()),
(
indoc! {"\
#(one|)#_cat
#[two|]#_dog
#(three|)#_cow
"},
"y<A-p>",
indoc! {"\
one#(one|)##(two|)##(three|)#_cat
two#(one|)##(two|)##[three|]#_dog
three#(one|)##(two|)##(three|)#_cow
"},
),
)
.await?;
Ok(())
}