11use std:: collections:: HashMap ;
2- use lib_ot:: core:: { DocumentTree , NodeData , Position , TransactionBuilder } ;
2+ use lib_ot:: core:: { DocumentTree , NodeData , TransactionBuilder } ;
33
44#[ test]
55fn main ( ) {
@@ -11,19 +11,25 @@ fn main() {
1111fn test_documents ( ) {
1212 let mut document = DocumentTree :: new ( ) ;
1313 let mut tb = TransactionBuilder :: new ( & document) ;
14- tb. insert_nodes ( & Position ( vec ! [ 0 ] ) , & vec ! [ NodeData :: new( "text" ) ] ) ;
14+ tb. insert_nodes ( & vec ! [ 0 ] . into ( ) , & vec ! [ NodeData :: new( "text" ) ] ) ;
1515 let transaction = tb. finalize ( ) ;
1616 document. apply ( transaction) ;
1717
18- assert ! ( document. node_at_path( & Position ( vec![ 0 ] ) ) . is_some( ) ) ;
19- let node = document. node_at_path ( & Position ( vec ! [ 0 ] ) ) . unwrap ( ) ;
18+ assert ! ( document. node_at_path( & vec![ 0 ] . into ( ) ) . is_some( ) ) ;
19+ let node = document. node_at_path ( & vec ! [ 0 ] . into ( ) ) . unwrap ( ) ;
2020 let node_data = document. arena . get ( node) . unwrap ( ) . get ( ) ;
2121 assert_eq ! ( node_data. node_type, "text" ) ;
2222
2323 let mut tb = TransactionBuilder :: new ( & document) ;
24- tb. update_attributes ( & Position ( vec ! [ 0 ] ) , HashMap :: from ( [
24+ tb. update_attributes ( & vec ! [ 0 ] . into ( ) , HashMap :: from ( [
2525 ( "subtype" . into ( ) , Some ( "bullet-list" . into ( ) ) ) ,
2626 ] ) ) ;
2727 let transaction = tb. finalize ( ) ;
2828 document. apply ( transaction) ;
29+
30+ let mut tb = TransactionBuilder :: new ( & document) ;
31+ tb. delete_node ( & vec ! [ 0 ] . into ( ) ) ;
32+ let transaction = tb. finalize ( ) ;
33+ document. apply ( transaction) ;
34+ assert ! ( document. node_at_path( & vec![ 0 ] . into( ) ) . is_none( ) ) ;
2935}
0 commit comments