Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: udpate test

appflowye711bfce1d77
diff --git a/shared-lib/lib-ot/src/core/document/document.rs b/shared-lib/lib-ot/src/core/document/document.rs
index ee7cb7111b..9ced1186d6 100644
--- a/shared-lib/lib-ot/src/core/document/document.rs
+++ b/shared-lib/lib-ot/src/core/document/document.rs
@@ -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() {
diff --git a/shared-lib/lib-ot/tests/main.rs b/shared-lib/lib-ot/tests/main.rs
index 8ac6aae55a..45164ecae3 100644
--- a/shared-lib/lib-ot/tests/main.rs
+++ b/shared-lib/lib-ot/tests/main.rs
@@ -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();