Skip to content

Commit

Permalink
Add a test for tags with newline.
Browse files Browse the repository at this point in the history
  • Loading branch information
teymour-aldridge committed Jul 23, 2022
1 parent 5596df9 commit 5578819
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib.rs
Expand Up @@ -149,3 +149,6 @@ pub mod element_ref;
pub mod html;
pub mod node;
pub mod selector;

#[cfg(test)]
mod test;
22 changes: 22 additions & 0 deletions src/test.rs
@@ -0,0 +1,22 @@
use crate::{Html, Selector};

#[test]
fn tag_with_newline() {
let selector = Selector::parse("a").unwrap();

let document = Html::parse_fragment(
r#"
<a
href="https://github.com/causal-agent/scraper">
</a>
"#,
);

let mut iter = document.select(&selector);
let a = iter.next().unwrap();
assert_eq!(
a.value().attr("href"),
Some("https://github.com/causal-agent/scraper")
);
}

0 comments on commit 5578819

Please sign in to comment.