1
0
Fork 0
mirror of https://gitlab.com/news-flash/article_scraper.git synced 2025-07-07 08:05:31 +02:00

fix tests

This commit is contained in:
Jan Lukas Gernert 2024-06-08 01:02:52 +02:00
parent 65b26370a2
commit 3e5654e197
2 changed files with 4 additions and 3 deletions

View file

@ -288,7 +288,7 @@ impl FullTextParser {
} }
} }
fn parse_html_string_patched( pub(crate) fn parse_html_string_patched(
input: &str, input: &str,
parser: &Parser, parser: &Parser,
) -> Result<Document, libxml::parser::XmlParseError> { ) -> Result<Document, libxml::parser::XmlParseError> {
@ -691,6 +691,7 @@ impl FullTextParser {
.ok() .ok()
.and_then(|()| node.set_property("width", "100%").ok()) .and_then(|()| node.set_property("width", "100%").ok())
.and_then(|()| node.set_property("height", "400").ok()) .and_then(|()| node.set_property("height", "400").ok())
.and_then(|()| node.remove_attribute("aspect-ratio").ok())
.ok_or_else(|| { .ok_or_else(|| {
node.unlink(); node.unlink();
video_wrapper.add_child(&mut node) video_wrapper.add_child(&mut node)

View file

@ -1259,14 +1259,14 @@ impl Util {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use libxml::parser::Parser; use libxml::parser::Parser;
use crate::FullTextParser;
use super::Util; use super::Util;
fn replace_brs(source: &str, expected: &str) { fn replace_brs(source: &str, expected: &str) {
libxml::tree::node::set_node_rc_guard(10); libxml::tree::node::set_node_rc_guard(10);
let parser = Parser::default_html(); let parser = Parser::default_html();
let document = parser.parse_string(source).unwrap(); let document = FullTextParser::parse_html_string_patched(source, &parser).unwrap();
let root = document.get_root_element().unwrap(); let root = document.get_root_element().unwrap();
let body = root.get_first_child().unwrap(); let body = root.get_first_child().unwrap();
let div = body.get_first_child().unwrap(); let div = body.get_first_child().unwrap();