@@ -230,56 +230,60 @@ def just_set_message_view(self: Any) -> None:
230
230
show_left_panel .assert_called_once_with (visible = True )
231
231
232
232
@pytest .mark .parametrize ("autohide" , [True , False ])
233
- @pytest .mark .parametrize ("visible, width" , [(True , LEFT_WIDTH ), (False , TAB_WIDTH )])
234
- def test_show_left_panel (
233
+ @pytest .mark .parametrize ("visible" , [True , False ])
234
+ @pytest .mark .parametrize ("test_method" , ["left_panel" , "right_panel" ])
235
+ def test_show_panel_methods (
235
236
self ,
236
237
mocker : MockerFixture ,
237
238
view : View ,
238
239
visible : bool ,
239
- width : int ,
240
240
autohide : bool ,
241
+ test_method : str ,
241
242
) -> None :
242
- view .body = mocker .Mock ()
243
- view .body .contents = [view .left_panel , mocker .Mock (), mocker .Mock ()]
243
+ view .frame .body = view .body
244
244
view .controller .autohide = autohide
245
+ expected_overlay_options = [
246
+ "" ,
247
+ None ,
248
+ "given" ,
249
+ 0 ,
250
+ None ,
251
+ 0 ,
252
+ 0 ,
253
+ "top" ,
254
+ None ,
255
+ "relative" ,
256
+ 100 ,
257
+ None ,
258
+ 0 ,
259
+ 0 ,
260
+ ]
261
+ if test_method == "left_panel" :
262
+ expected_overlay_options [0 ] = "left"
263
+ expected_overlay_options [3 ] = LEFT_WIDTH + 1
264
+ expected_tab = view .left_tab
265
+ expected_panel = view .left_panel
245
266
246
- view .show_left_panel (visible = visible )
247
-
248
- if autohide :
249
- if visible :
250
- assert view .body .contents [0 ][0 ] == view .left_panel
251
- else :
252
- assert view .body .contents [0 ][0 ] == view .left_tab
253
- view .body .options .assert_called_once_with ("given" , width )
267
+ view .show_left_panel (visible = visible )
254
268
else :
255
- view .body .options .assert_not_called ()
269
+ expected_overlay_options [0 ] = "right"
270
+ expected_overlay_options [3 ] = RIGHT_WIDTH + 1
271
+ expected_tab = view .right_tab
272
+ expected_panel = view .right_panel
256
273
257
- @pytest .mark .parametrize ("autohide" , [True , False ])
258
- @pytest .mark .parametrize (
259
- "visible, width" , [(True , RIGHT_WIDTH ), (False , TAB_WIDTH )]
260
- )
261
- def test_show_right_panel (
262
- self ,
263
- mocker : MockerFixture ,
264
- view : View ,
265
- visible : bool ,
266
- width : int ,
267
- autohide : bool ,
268
- ) -> None :
269
- view .body = mocker .Mock ()
270
- view .body .contents = [mocker .Mock (), mocker .Mock (), view .right_panel ]
271
- view .controller .autohide = autohide
272
-
273
- view .show_right_panel (visible = visible )
274
+ view .show_right_panel (visible = visible )
274
275
275
276
if autohide :
276
277
if visible :
277
- assert view .body .contents [2 ][0 ] == view .right_panel
278
+ assert (expected_panel , mocker .ANY ) in view .frame .body .top_w .contents
279
+ assert view .frame .body .bottom_w == view .body
280
+ assert view .frame .body .contents [1 ][1 ] == tuple (expected_overlay_options )
278
281
else :
279
- assert view .body .contents [2 ][0 ] == view . right_tab
280
- view .body .options . assert_called_once_with ( "given" , width )
282
+ assert view .frame . body .contents [0 ][0 ] == expected_tab
283
+ assert view .body .focus_position == 1
281
284
else :
282
- view .body .options .assert_not_called ()
285
+ # No change
286
+ assert view .frame .body .contents [0 ][0 ] == expected_tab
283
287
284
288
def test_keypress_normal_mode_navigation (
285
289
self ,
@@ -359,7 +363,7 @@ def test_keypress_autohide_users(
359
363
view .right_panel = mocker .Mock ()
360
364
size = widget_size (view )
361
365
view .controller .is_in_editor_mode = lambda : False
362
- view .body .focus_position = None
366
+ view .body .focus_position = 1
363
367
364
368
view .keypress (size , key )
365
369
0 commit comments