MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / deep_nested_block_change

Function deep_nested_block_change

nodedb/src/event/field_diff.rs:422–449  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

420
421 #[test]
422 fn deep_nested_block_change() {
423 let old = json!({
424 "blocks": [
425 {"id": "blk-1", "type": "heading", "content": "Intro"},
426 {"id": "blk-2", "type": "list", "children": [
427 {"id": "blk-3", "content": "Item A"},
428 {"id": "blk-4", "content": "Item B"}
429 ]}
430 ]
431 });
432 let new = json!({
433 "blocks": [
434 {"id": "blk-1", "type": "heading", "content": "Introduction"},
435 {"id": "blk-2", "type": "list", "children": [
436 {"id": "blk-3", "content": "Item A"},
437 {"id": "blk-4", "content": "Item C"}
438 ]}
439 ]
440 });
441 let diffs = compute_field_diffs(&old, &new);
442 assert_eq!(diffs.len(), 2);
443 assert!(diffs.iter().any(|d| d.field == "blocks[0].content"));
444 assert!(
445 diffs
446 .iter()
447 .any(|d| d.field == "blocks[1].children[1].content")
448 );
449 }
450
451 #[test]
452 fn insert_only_no_old_value() {

Callers

nothing calls this directly

Calls 1

compute_field_diffsFunction · 0.85

Tested by

no test coverage detected