write tests for within selector

This commit is contained in:
Schrottkatze 2025-02-16 20:50:22 +01:00
parent 5fb96b28b4
commit 2ac47bc13e
No known key found for this signature in database
2 changed files with 24 additions and 0 deletions

BIN
tests/ref/query-within.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 B

View File

@ -250,3 +250,27 @@
t("b") t("b")
block(height: 1fr, metadata("b")) block(height: 1fr, metadata("b"))
} }
--- query-within ---
#let test-selector(selector, ref) = context {
test(query(selector).map(e => e.body), ref)
}
= A #strong[a] #label("strong")
#strong[b] #label("strong")
== B
== C #strong[c] #label("strong")
>
#test-selector(
selector(<strong>).within(heading),
([a], [c]),
)
#test-selector(
selector(<strong>).within(heading.where(level: 2)),
([c], ),
)