1111 current_hook ,
1212 strictly_equal ,
1313)
14- from idom .core .layout import Layout
15- from idom .core .serve import render_json_patch
14+ from idom .core .layout import Layout , LayoutUpdate
1615from idom .testing import DisplayFixture , HookCatcher , assert_idom_did_log , poll
1716from idom .testing .logs import assert_idom_did_not_log
1817from idom .utils import Ref
19- from tests .tooling .asserts import assert_same_items
2018
2119
2220async def test_must_be_rendering_in_layout_to_use_hooks ():
@@ -42,31 +40,35 @@ def SimpleStatefulComponent():
4240 sse = SimpleStatefulComponent ()
4341
4442 async with idom .Layout (sse ) as layout :
45- patch_1 = await render_json_patch (layout )
46- assert patch_1 .path == ""
47- assert_same_items (
48- patch_1 .changes ,
49- [
50- {"op" : "add" , "path" : "/tagName" , "value" : "" },
51- {
52- "op" : "add" ,
53- "path" : "/children" ,
54- "value" : [{"children" : ["0" ], "tagName" : "div" }],
55- },
56- ],
43+ update_1 = await layout .render ()
44+ assert update_1 == LayoutUpdate (
45+ path = "" ,
46+ old = None ,
47+ new = {
48+ "tagName" : "" ,
49+ "children" : [{"tagName" : "div" , "children" : ["0" ]}],
50+ },
5751 )
5852
59- patch_2 = await render_json_patch (layout )
60- assert patch_2 .path == ""
61- assert patch_2 .changes == [
62- {"op" : "replace" , "path" : "/children/0/children/0" , "value" : "1" }
63- ]
64-
65- patch_3 = await render_json_patch (layout )
66- assert patch_3 .path == ""
67- assert patch_3 .changes == [
68- {"op" : "replace" , "path" : "/children/0/children/0" , "value" : "2" }
69- ]
53+ update_2 = await layout .render ()
54+ assert update_2 == LayoutUpdate (
55+ path = "" ,
56+ old = update_1 .new ,
57+ new = {
58+ "tagName" : "" ,
59+ "children" : [{"tagName" : "div" , "children" : ["1" ]}],
60+ },
61+ )
62+
63+ update_3 = await layout .render ()
64+ assert update_3 == LayoutUpdate (
65+ path = "" ,
66+ old = update_2 .new ,
67+ new = {
68+ "tagName" : "" ,
69+ "children" : [{"tagName" : "div" , "children" : ["2" ]}],
70+ },
71+ )
7072
7173
7274async def test_set_state_callback_identity_is_preserved ():
0 commit comments