oficina / docs Public

Clone
git clone https://amadan.net/oficina/docs

Plain git — no account needed to clone.

Download

Download this file

1use docs_native_crdt::Editor;
2use serde_json::json;
3
4#[test]
5fn every_rule_delta_converges_with_remote_apply() {
6 for fresh in [false, true] {
7 let mut authority = Editor::new("rule-delta-convergence", 800);
8 let remote = Editor::new("rule-delta-convergence", 900);
9 let initial = authority.command(&json!({"op":"insert_element","at":0,"type":"paragraph"})).unwrap();
10 remote.apply(&initial).unwrap();
11 let mut source = Editor::new("rule-delta-convergence", 801);
12 source.apply(&authority.snapshot()).unwrap();
13 for (index, command) in [
14 json!({"op":"display_edit","at":0,"length":0,"text":"-"}),
15 json!({"op":"display_autoformat","at":0,"length":1,"kind":"bullet_list","level":0}),
16 json!({"op":"display_revert_rule","at":0,"kind":"bullet_list","prior_type":"paragraph","prior_attrs":{},"text":"- "}),
17 json!({"op":"display_edit","at":2,"length":0,"text":"Alpha"}),
18 json!({"op":"display_edit","at":7,"length":0,"text":"\n"}),
19 json!({"op":"display_edit","at":8,"length":0,"text":"Beta"}),
20 ].iter().enumerate() {
21 if fresh { source = Editor::new("rule-delta-convergence", 810 + index as u64); source.apply(&authority.snapshot()).unwrap(); }
22 let delta = source.command(command).unwrap();
23 authority.apply_local(&delta).unwrap();
24 remote.apply(&delta).unwrap();
25 assert_eq!(authority.projection()["children"], remote.projection()["children"], "fresh={fresh}, step={index}, command={command}");
26 }
27 }
28}
29