chore: udpate test

This commit is contained in:
appflowy 2022-09-08 19:21:06 +08:00
parent d386698e97
commit e711bfce1d
2 changed files with 14 additions and 2 deletions

View file

@ -84,7 +84,7 @@ impl DocumentTree {
counter
}
fn child_at_index_of_path(&self, at_node: NodeId, index: usize) -> Option<NodeId> {
pub fn child_at_index_of_path(&self, at_node: NodeId, index: usize) -> Option<NodeId> {
let children = at_node.children(&self.arena);
for (counter, child) in children.enumerate() {

View file

@ -1,4 +1,4 @@
use lib_ot::core::{DocumentTree, NodeAttributes, NodeSubTree, Path, TransactionBuilder};
use lib_ot::core::{DocumentOperation, DocumentTree, NodeAttributes, NodeSubTree, Path, TransactionBuilder};
use lib_ot::errors::OTErrorCode;
use std::collections::HashMap;
@ -85,6 +85,18 @@ fn test_inserts_subtrees() {
assert_eq!(data.node_type, "image");
}
#[test]
fn test_insert_node() {
let node = NodeSubTree::new("text");
let root_path: Path = vec![0].into();
let op = DocumentOperation::Insert {path: root_path.clone(),nodes: vec![node.clone()] };
let mut document = DocumentTree::new();
document.apply_op(&op).unwrap();
let node_id = document.node_at_path(&root_path).unwrap();
assert!(document.child_at_index_of_path(node_id, 0).is_some());
}
#[test]
fn test_update_nodes() {
let mut document = DocumentTree::new();