use super::*; mod simple { use super::*; #[tokio::test(flavor = "multi_thread")] async fn uncomment_inner_injection() -> anyhow::Result<()> { test(( indoc! {r#"\
Comment toggle on this line should use the HTML comment token(s).
"#}, ":lang htmlComment toggle on this line should use the HTML comment token(s).
"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn comment_inner_injection() -> anyhow::Result<()> { test(( indoc! {r#"\Comment toggle on this line should use the HTML comment token(s).
"#}, ":lang htmlComment toggle on this line should use the HTML comment token(s).
"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn block_comment_inner_injection() -> anyhow::Result<()> { test(( indoc! {r#"\Comment toggle on this line should use the HTML comment token(s).
"#}, ":lang htmlComment toggle on this line should use the HTML comment token(s).
"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn block_uncomment_inner_injection() -> anyhow::Result<()> { test(( indoc! {r#"\Comment toggle on this line should use the HTML comment token(s).
"#}, ":lang htmlComment toggle on this line should use the HTML comment token(s).
"#}, )) .await?; Ok(()) } } mod injected_comment_tokens_continue_comment { use super::*; #[tokio::test(flavor = "multi_thread")] async fn adds_new_comment_on_newline() -> anyhow::Result<()> { test(( indoc! {r#"Some text 1234
"#}, ":lang htmlSome text 1234
"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn continues_comment() -> anyhow::Result<()> { test(( indoc! {r#"\Some text 1234
"#}, ":lang htmlSome text 1234
"#}, )) .await?; Ok(()) } } #[tokio::test(flavor = "multi_thread")] async fn test_injected_comment_tokens_continue_comment_d() -> anyhow::Result<()> { test(( indoc! {r#"\Some text 1234
"#}, ":lang htmlSome text 1234
"#}, )) .await?; Ok(()) } mod multiple_selections_different_injection_layers { use super::*; #[tokio::test(flavor = "multi_thread")] async fn comments_two_different_injection_layers_with_different_comments() -> anyhow::Result<()> { test(( indoc! {r#"\Comment toggle #[|on this line ]#should use the HTML comment token(s).
"#}, ":lang htmlComment toggle #[|on this line ]#should use the HTML comment token(s).
"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn works_with_multiple_selections() -> anyhow::Result<()> { test(( indoc! {r#"\Comment toggle #(|on this line )#should use the HTML comment token(s).
"#}, ":lang htmlComment toggle #(|on this line)# should use the HTML comment token(s).
"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn full_line_selection_commenting() -> anyhow::Result<()> { test(( indoc! {r#"\Comment toggle on this line should use the HTML comment token(s).
"#}, ":lang htmlComment toggle on this line should use the HTML comment token(s).
"#}, )) .await?; test(( indoc! {r#"\Comment toggle on this line should use the HTML comment token(s).
"#}, ":lang htmlComment toggle on this line should use the HTML comment token(s).
"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn block_comment_toggle_across_different_layers() -> anyhow::Result<()> { test(( indoc! {r#"\Comment toggle #(|on this line)# should use the HTML comment token(s).
"#}, ":lang htmlComment toggle #(|)# should use the HTML comment token(s).
"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn multiple_selections_same_line() -> anyhow::Result<()> { test(( indoc! {r#"\C#[|o]#mment t#(|o)#ggle #(|o)#n this line sh#(|o)#uld use the HTML c#(|o)#mment t#(|o)#ken(s).
"#}, ":lang htmlC#[|]#mment t#(|)#ggle #(|)#n this line sh#(|)#uld use the HTML c#(|)#mment t#(|)#ken(s).
"#}, )) .await?; test(( indoc! {r#"\C#[|]#mment t#(|)#ggle #(|)#n this line sh#(|)#uld use the HTML c#(|)#mment t#(|)#ken(s).
"#}, ":lang htmlC#[|o]#mment t#(|o)#ggle #(|o)#n this line sh#(|o)#uld use the HTML c#(|o)#mment t#(|o)#ken(s).
"#}, )) .await?; Ok(()) } #[tokio::test(flavor = "multi_thread")] async fn many_single_line_selections() -> anyhow::Result<()> { test(( indoc! {r#"\C#[|o]#mment t#(|o)#ggle #(|o)#n this line sh#(|o)#uld use the HTML c#(|o)#mment t#(|o)#ken(s).
"#}, ":lang htmlC#[|]#mment t#(|)#ggle #(|)#n this line sh#(|)#uld use the HTML c#(|)#mment t#(|)#ken(s).
"#}, )) .await?; test(( indoc! {r#"\C#[|]#mment t#(|)#ggle #(|)#n this line sh#(|)#uld use the HTML c#(|)#mment t#(|)#ken(s).
"#}, ":lang htmlC#[|o]#mment t#(|o)#ggle #(|o)#n this line sh#(|o)#uld use the HTML c#(|o)#mment t#(|o)#ken(s).
"#}, )) .await?; Ok(()) } } /// A selection that spans across several injections takes comment tokens /// from the injection with the bigger scope #[tokio::test(flavor = "multi_thread")] async fn test_injected_comment_tokens_selection_across_different_layers() -> anyhow::Result<()> { test(( indoc! {r#"\Comment tog#[|gle on this line should use the HTML comment token(s).
"#}, ":lang htmlComment tog#[|gle on this line should use the HTML comment token(s).
"#}, ":lang htmlComment tog#[|]#le on this line should use the javascript comment token(s).
foo();
"#},
))
.await?;
Ok(())
}
#[tokio::test(flavor = "multi_thread")]
async fn test_join_selections_comment() -> anyhow::Result<()> {
test((
indoc! {"\
/// #[a|]#bc
/// def
"},
":lang rust