mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: udpate test
This commit is contained in:
parent
d386698e97
commit
e711bfce1d
@ -84,7 +84,7 @@ impl DocumentTree {
|
|||||||
counter
|
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);
|
let children = at_node.children(&self.arena);
|
||||||
|
|
||||||
for (counter, child) in children.enumerate() {
|
for (counter, child) in children.enumerate() {
|
||||||
|
@ -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 lib_ot::errors::OTErrorCode;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
@ -85,6 +85,18 @@ fn test_inserts_subtrees() {
|
|||||||
assert_eq!(data.node_type, "image");
|
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]
|
#[test]
|
||||||
fn test_update_nodes() {
|
fn test_update_nodes() {
|
||||||
let mut document = DocumentTree::new();
|
let mut document = DocumentTree::new();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user