use ruma_html::Html; #[test] fn navigate_tree() { let raw_html = "\
This is some text
\` element. let p_node = div_children.next().unwrap(); let p_element = p_node.as_element().unwrap(); assert_eq!(&p_element.name.local, "p"); assert!(p_element.attrs.borrow().is_empty()); assert!(p_node.parent().is_some()); assert!(p_node.next_sibling().is_none()); assert!(p_node.prev_sibling().is_none()); assert!(p_node.has_children()); assert!(p_node.first_child().is_some()); assert!(p_node.last_child().is_some()); let mut p_children = p_node.children(); // Text of `
` element. let p_text_node = p_children.next().unwrap(); let p_text = p_text_node.as_text().unwrap(); assert_eq!(p_text.borrow().as_ref(), "This is some "); assert!(p_text_node.parent().is_some()); assert!(p_text_node.next_sibling().is_some()); assert!(p_text_node.prev_sibling().is_none()); assert!(!p_text_node.has_children()); assert!(p_text_node.first_child().is_none()); assert!(p_text_node.last_child().is_none()); let mut p_text_children = p_text_node.children(); assert!(p_text_children.next().is_none()); // `` element. let em_node = p_children.next().unwrap(); let em_element = em_node.as_element().unwrap(); assert_eq!(&em_element.name.local, "em"); assert!(em_element.attrs.borrow().is_empty()); assert!(em_node.parent().is_some()); assert!(em_node.next_sibling().is_none()); assert!(em_node.prev_sibling().is_some()); assert!(em_node.has_children()); assert!(em_node.first_child().is_some()); assert!(em_node.last_child().is_some()); let mut em_children = em_node.children(); // Text of `` element. let em_text_node = em_children.next().unwrap(); let em_text = em_text_node.as_text().unwrap(); assert_eq!(em_text.borrow().as_ref(), "text"); assert!(em_text_node.parent().is_some()); assert!(em_text_node.next_sibling().is_none()); assert!(em_text_node.prev_sibling().is_none()); assert!(!em_text_node.has_children()); assert!(em_text_node.first_child().is_none()); assert!(em_text_node.last_child().is_none()); let mut em_text_children = em_text_node.children(); assert!(em_text_children.next().is_none()); assert!(em_children.next().is_none()); assert!(p_children.next().is_none()); assert!(div_children.next().is_none()); assert!(html_children.next().is_none()); }