MCPcopy Create free account
hub / github.com/d0iasm/saba / test_body

Function test_body

core/src/renderer/html/parser.rs:747–790  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

745
746 #[test]
747 fn test_body() {
748 let browser = Browser::new();
749 let html = "<html><head></head><body></body></html>".to_string();
750 let t = HtmlTokenizer::new(Rc::downgrade(&browser), html);
751 let window = HtmlParser::new(Rc::downgrade(&browser), t).construct_tree();
752 let document = window.borrow().document();
753 assert_eq!(
754 Rc::new(RefCell::new(Node::new(NodeKind::Document))),
755 document
756 );
757 let html = document
758 .borrow()
759 .first_child()
760 .expect("failed to get a first child of document");
761 assert_eq!(
762 Rc::new(RefCell::new(Node::new(NodeKind::Element(Element::new(
763 "html",
764 Vec::new()
765 ))))),
766 html
767 );
768 let head = html
769 .borrow()
770 .first_child()
771 .expect("failed to get a first child of html");
772 assert_eq!(
773 Rc::new(RefCell::new(Node::new(NodeKind::Element(Element::new(
774 "head",
775 Vec::new()
776 ))))),
777 head
778 );
779 let body = head
780 .borrow()
781 .next_sibling()
782 .expect("failed to get a next sibling of head");
783 assert_eq!(
784 Rc::new(RefCell::new(Node::new(NodeKind::Element(Element::new(
785 "body",
786 Vec::new()
787 ))))),
788 body
789 );
790 }
791
792 #[test]
793 fn test_text() {

Callers

nothing calls this directly

Calls 5

to_stringMethod · 0.80
construct_treeMethod · 0.80
documentMethod · 0.80
first_childMethod · 0.45
next_siblingMethod · 0.45

Tested by

no test coverage detected