()
| 596 | |
| 597 | #[test] |
| 598 | fn test_edit_document() { |
| 599 | let mut doc = Document::parse_with_options( |
| 600 | b"<html><body><a></a><b></b></body></html>", |
| 601 | 0, |
| 602 | InliningMode::Document, |
| 603 | ); |
| 604 | let a_id = NodeId::new(5); |
| 605 | assert_eq!( |
| 606 | doc[a_id].as_element().expect("Element does not exist").name, |
| 607 | QualName::new(None, ns!(html), local_name!("a")) |
| 608 | ); |
| 609 | let b_id = NodeId::new(6); |
| 610 | assert_eq!( |
| 611 | doc[b_id].as_element().expect("Element does not exist").name, |
| 612 | QualName::new(None, ns!(html), local_name!("b")) |
| 613 | ); |
| 614 | // `a` is the previous sibling of `b` |
| 615 | // `b` is the next sibling of `a` |
| 616 | assert_eq!(doc[b_id].previous_sibling, Some(a_id)); |
| 617 | assert_eq!(doc[a_id].next_sibling, Some(b_id)); |
| 618 | // Detach `b`, so it has no previous sibling |
| 619 | // And `a` has not next sibling |
| 620 | doc.detach(b_id); |
| 621 | assert_eq!(doc[b_id].previous_sibling, None); |
| 622 | assert_eq!(doc[a_id].next_sibling, None); |
| 623 | let head_id = NodeId::new(3); |
| 624 | let body_id = NodeId::new(4); |
| 625 | // Detach `head`, so previous sibling of `body` is empty |
| 626 | doc.detach(head_id); |
| 627 | assert_eq!(doc[body_id].next_sibling, None); |
| 628 | } |
| 629 | } |
nothing calls this directly
no test coverage detected