2020 assert_idom_logged ,
2121 capture_idom_logs ,
2222)
23- from tests .general_utils import assert_same_items
23+ from tests .assert_utils import assert_same_items
2424
2525
2626@pytest .fixture (autouse = True )
@@ -79,13 +79,21 @@ def SimpleComponent():
7979 path , changes = await render_json_patch (layout )
8080
8181 assert path == ""
82- assert changes == [{"op" : "add" , "path" : "/tagName" , "value" : "div" }]
82+ assert_same_items (
83+ changes ,
84+ [
85+ {"op" : "add" , "path" : "/children" , "value" : [{"tagName" : "div" }]},
86+ {"op" : "add" , "path" : "/tagName" , "value" : "" },
87+ ],
88+ )
8389
8490 set_state_hook .current ("table" )
8591 path , changes = await render_json_patch (layout )
8692
8793 assert path == ""
88- assert changes == [{"op" : "replace" , "path" : "/tagName" , "value" : "table" }]
94+ assert changes == [
95+ {"op" : "replace" , "path" : "/children/0/tagName" , "value" : "table" }
96+ ]
8997
9098
9199async def test_nested_component_layout ():
@@ -112,23 +120,38 @@ def Child():
112120 {
113121 "op" : "add" ,
114122 "path" : "/children" ,
115- "value" : ["0" , {"tagName" : "div" , "children" : ["0" ]}],
123+ "value" : [
124+ {
125+ "children" : [
126+ "0" ,
127+ {
128+ "children" : [{"children" : ["0" ], "tagName" : "div" }],
129+ "tagName" : "" ,
130+ },
131+ ],
132+ "tagName" : "div" ,
133+ }
134+ ],
116135 },
117- {"op" : "add" , "path" : "/tagName" , "value" : "div " },
136+ {"op" : "add" , "path" : "/tagName" , "value" : "" },
118137 ],
119138 )
120139
121140 parent_set_state .current (1 )
122141 path , changes = await render_json_patch (layout )
123142
124143 assert path == ""
125- assert changes == [{"op" : "replace" , "path" : "/children/0" , "value" : "1" }]
144+ assert changes == [
145+ {"op" : "replace" , "path" : "/children/0/children/0" , "value" : "1" }
146+ ]
126147
127148 child_set_state .current (1 )
128149 path , changes = await render_json_patch (layout )
129150
130151 assert path == "/children/1"
131- assert changes == [{"op" : "replace" , "path" : "/children/0" , "value" : "1" }]
152+ assert changes == [
153+ {"op" : "replace" , "path" : "/children/0/children/0" , "value" : "1" }
154+ ]
132155
133156
134157@pytest .mark .skipif (
@@ -202,16 +225,21 @@ def BadChild():
202225 assert_same_items (
203226 patch .changes ,
204227 [
228+ {"op" : "add" , "path" : "/tagName" , "value" : "" },
205229 {
206230 "op" : "add" ,
207231 "path" : "/children" ,
208232 "value" : [
209- {"tagName" : "div" , "children" : ["hello" ]},
210- {"tagName" : "" , "error" : "" },
211- {"tagName" : "div" , "children" : ["hello" ]},
233+ {
234+ "children" : [
235+ {"children" : [...], "tagName" : "" },
236+ {"error" : "" , "tagName" : "" },
237+ {"children" : [...], "tagName" : "" },
238+ ],
239+ "tagName" : "div" ,
240+ }
212241 ],
213242 },
214- {"op" : "add" , "path" : "/tagName" , "value" : "div" },
215243 ],
216244 )
217245
@@ -233,9 +261,24 @@ def Child():
233261 {
234262 "op" : "add" ,
235263 "path" : "/children" ,
236- "value" : [{"tagName" : "div" , "children" : [{"tagName" : "h1" }]}],
264+ "value" : [
265+ {
266+ "children" : [
267+ {
268+ "children" : [
269+ {
270+ "children" : [{"tagName" : "h1" }],
271+ "tagName" : "div" ,
272+ }
273+ ],
274+ "tagName" : "" ,
275+ }
276+ ],
277+ "tagName" : "div" ,
278+ }
279+ ],
237280 },
238- {"op" : "add" , "path" : "/tagName" , "value" : "div " },
281+ {"op" : "add" , "path" : "/tagName" , "value" : "" },
239282 ],
240283 )
241284
@@ -422,7 +465,7 @@ def Child():
422465 hook .latest .schedule_render ()
423466
424467 update = await render_json_patch (layout )
425- assert update .path == "/children/0/children/0"
468+ assert update .path == "/children/0/children/0/children/0 "
426469
427470
428471async def test_log_on_dispatch_to_missing_event_handler (caplog ):
0 commit comments