feat: add integration tests for commenting through injection layers

pull/12759/head
Nikita Revenco 2025-02-01 21:32:53 +00:00 committed by Nik Revenco
parent 0a882107ed
commit 7c24110061
2 changed files with 141 additions and 1 deletions

View File

@ -653,6 +653,141 @@ async fn test_join_selections_space() -> anyhow::Result<()> {
Ok(())
}
#[tokio::test(flavor = "multi_thread")]
async fn test_injected_comments() -> anyhow::Result<()> {
// Uncomment inner injection
test((
indoc! {r#"\
<p>C-c on this line should use the HTML comment token(s).</p>
<script type="text/javascript">
// C-c#[| on this line s]#hould use the javascript comment token(s).
foo();
</script>
"#},
":lang html<ret><C-c>",
indoc! {r#"\
<p>C-c on this line should use the HTML comment token(s).</p>
<script type="text/javascript">
C-c#[| on this line s]#hould use the javascript comment token(s).
foo();
</script>
"#},
))
.await?;
// Comment inner injection
test((
indoc! {r#"\
<p>C-c on this line should use the HTML comment token(s).</p>
<script type="text/javascript">
C-c#[| on this line s]#hould use the javascript comment token(s).
foo();
</script>
"#},
":lang html<ret><C-c>",
indoc! {r#"\
<p>C-c on this line should use the HTML comment token(s).</p>
<script type="text/javascript">
// C-c#[| on this line s]#hould use the javascript comment token(s).
foo();
</script>
"#},
))
.await?;
// Comments two different injection layers with different comments
test((
indoc! {r#"\
<p>C-c #[|on this line ]#should use the HTML comment token(s).</p>
<script type="text/javascript">
C-c #(|on this line )#should use the javascript comment token(s).
foo();
</script>
"#},
":lang html<ret><C-c>",
indoc! {r#"\
<!-- <p>C-c #[|on this line ]#should use the HTML comment token(s).</p> -->
<script type="text/javascript">
// C-c #(|on this line )#should use the javascript comment token(s).
foo();
</script>
"#},
))
.await?;
// Uncomments two different injection layers with different comments
test((
indoc! {r#"\
<!-- <p>C-c #[|on this line ]#should use the HTML comment token(s).</p> -->
<script type="text/javascript">
// C-c #(|on this line )#should use the javascript comment token(s).
foo();
</script>
"#},
":lang html<ret><C-c>",
indoc! {r#"\
<p>C-c #[|on this line ]#should use the HTML comment token(s).</p>
<script type="text/javascript">
C-c #(|on this line )#should use the javascript comment token(s).
foo();
</script>
"#},
))
.await?;
// Works with multiple selections
test((
indoc! {r#"\
<p>C-c #(|on this line )#should use the HTML comment token(s).</p>
<script type="text/javascript">
// C-c #[|on this line ]#should use the javascript comment token(s).
foo();
</script>
"#},
":lang html<ret><C-c>",
indoc! {r#"\
<!-- <p>C-c #(|on this line )#should use the HTML comment token(s).</p> -->
<script type="text/javascript">
C-c #[|on this line ]#should use the javascript comment token(s).
foo();
</script>
"#},
))
.await?;
// Works with nested injection layers: html, js then css
test((
indoc! {r#"\
<!-- <p>C-c #(|on this line)# should use the HTML comment token(s).</p> -->
<script type="text/javascript">
// C-c #(|on this line)# should use the javascript comment token(s).
foo();
css`
h#[tml {
background-color: |]#red;
}
`
</script>
"#},
":lang html<ret><C-c>",
indoc! {r#"\
<p>C-c #(|on this line)# should use the HTML comment token(s).</p>
<script type="text/javascript">
C-c #(|on this line)# should use the javascript comment token(s).
foo();
css`
/* h#[tml { */
/* background-color: |]#red; */
}
`
</script>
"#},
))
.await?;
Ok(())
}
#[tokio::test(flavor = "multi_thread")]
async fn test_join_selections_comment() -> anyhow::Result<()> {
test((

View File

@ -1,5 +1,10 @@
<p>C-c on this line should use the HTML comment token(s).</p>
<!-- <p>C-c on this line should use the HTML comment token(s).</p> -->
<script type="text/javascript">
// C-c on this line should use the javascript comment token(s).
foo();
css`
html {
background-color: red;
}
`;
</script>