use std::collections::HashMap; use html_query_parser::{parse, Editable, Htmlifiable, Node, Selector}; const HTML: &str = r#" Document "#; const INSERTED_HTML: &str = r#" Document "#; const REMOVED_HTML: &str = r#" Document "#; #[test] fn insert() { let body_selector = Selector::from("body"); let script = Node::Element { name: "script".to_string(), attrs: HashMap::new(), children: vec![Node::Text(r#"console.log("Hello World")"#.to_string())], }; let html = parse(HTML).insert_to(&body_selector, script).html(); assert_eq!(html, INSERTED_HTML); } #[test] fn remove() { let meta_selector = Selector::from("meta"); let html = parse(HTML).remove_by(&meta_selector).html(); assert_eq!(html, REMOVED_HTML); }