aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-08-16 07:46:50 +0200
committerMartin Fischer <martin@push-f.com>2023-08-19 13:41:55 +0200
commita48ddc21a26f394e077e7bd80ef96b2c281e7730 (patch)
treeb49d5c01b0fffeab2f66c00ec33bd11a5962ee25 /tests
parent0d96df198b1223e942abfefb7ea51ccab99638cc (diff)
feat!: add all-inclusive spans to tags
Also more performant since we no longer have to update the name span on every Emitter::push_tag_name call.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_spans.rs34
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/test_spans.rs b/tests/test_spans.rs
index a33c2b3..33f5d11 100644
--- a/tests/test_spans.rs
+++ b/tests/test_spans.rs
@@ -44,12 +44,42 @@ fn annotate(html: &str, labels: Vec<(Range<usize>, impl AsRef<str>)>) -> String
}
#[test]
+fn start_tag_span() {
+ let html = "<x> <xyz> <xyz > <xyz/>";
+ let mut labels = Vec::new();
+ for token in tokenizer(html) {
+ if let Token::StartTag(tag) = token {
+ labels.push((tag.span, ""));
+ }
+ }
+ assert_snapshot!(annotate(html, labels), @r###"
+ <x> <xyz> <xyz > <xyz/>
+ ^^^ ^^^^^ ^^^^^^^ ^^^^^^
+ "###);
+}
+
+#[test]
+fn end_tag_span() {
+ let html = "</x> </xyz> </xyz > </xyz/>";
+ let mut labels = Vec::new();
+ for token in tokenizer(html) {
+ if let Token::EndTag(tag) = token {
+ labels.push((tag.span, ""));
+ }
+ }
+ assert_snapshot!(annotate(html, labels), @r###"
+ </x> </xyz> </xyz > </xyz/>
+ ^^^^ ^^^^^^ ^^^^^^^^ ^^^^^^^
+ "###);
+}
+
+#[test]
fn start_tag_name_span() {
let html = "<x> <xyz> <xyz > <xyz/>";
let mut labels = Vec::new();
for token in tokenizer(html) {
if let Token::StartTag(tag) = token {
- labels.push((tag.name_span, ""));
+ labels.push((tag.name_span(), ""));
}
}
assert_snapshot!(annotate(html, labels), @r###"
@@ -64,7 +94,7 @@ fn end_tag_name_span() {
let mut labels = Vec::new();
for token in tokenizer(html) {
if let Token::EndTag(tag) = token {
- labels.push((tag.name_span, ""));
+ labels.push((tag.name_span(), ""));
}
}
assert_snapshot!(annotate(html, labels), @r###"