From 2da718db8f9dceedd3e2aa2869bd628f8e067321 Mon Sep 17 00:00:00 2001 From: Issac Kelly Date: Tue, 29 Nov 2022 13:53:54 -0800 Subject: [PATCH] Add transaction test --- autosurgeon/src/reconcile.rs | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/autosurgeon/src/reconcile.rs b/autosurgeon/src/reconcile.rs index ca72c48..564e313 100644 --- a/autosurgeon/src/reconcile.rs +++ b/autosurgeon/src/reconcile.rs @@ -1067,4 +1067,53 @@ mod tests { }} ); } + + fn test_prop_with_transaction() { + let mut doc = automerge::Automerge::new(); + let mut tx = doc.transaction(); + + let bob = Contact { + name: "bob".to_string(), + id: 1, + addresses: vec![Address { + line_one: "line one".to_string(), + line_two: "line two".to_string(), + }], + }; + reconcile(&mut tx, &bob).unwrap(); + tx.commit(); + + assert_doc!( + &doc, + map! { + "name" => { "bob" }, + "id" => { 1_u64 }, + "addresses" => { list!{ + { map! { + "line_one" => { "line one" }, + "line_two" => { "line two" }, + }} + } + }} + ); + + let mut tx = doc.transaction(); + reconcile_prop(&mut tx, automerge::ROOT, "name", "Alice".to_owned()).unwrap(); + tx.commit(); + + assert_doc!( + &doc, + map! { + "name" => { "alice" }, + "id" => { 1_u64 }, + "addresses" => { list!{ + { map! { + "line_one" => { "line one" }, + "line_two" => { "line two" }, + }} + } + }} + ); + + } }