@@ -360,6 +360,33 @@ class OptionDataclassTestFixture(t.NamedTuple):
360
360
"xterm*" : ["clipboard" , "ccolour" , "cstyle" , "focus" ],
361
361
},
362
362
),
363
+ OptionDataclassTestFixture (
364
+ test_id = "command-alias" ,
365
+ option_data = textwrap .dedent (
366
+ """
367
+ command-alias[0] split-pane=split-window
368
+ command-alias[1] splitp=split-window
369
+ command-alias[2] "server-info=show-messages -JT"
370
+ command-alias[3] "info=show-messages -JT"
371
+ command-alias[4] "choose-window=choose-tree -w"
372
+ command-alias[5] "choose-session=choose-tree -s"
373
+ """ ,
374
+ )
375
+ .strip ()
376
+ .split ("\n " ),
377
+ dataclass_attribute = "command_alias" ,
378
+ tmux_option = "command-alias" ,
379
+ expected = TmuxArray (
380
+ {
381
+ "split-pane" : "split-window" ,
382
+ "splitp" : "split-window" ,
383
+ "server-info" : "show-messages -JT" ,
384
+ "info" : "show-messages -JT" ,
385
+ "choose-window" : "choose-tree -w" ,
386
+ "choose-session" : "choose-tree -s" ,
387
+ },
388
+ ),
389
+ ),
363
390
]
364
391
365
392
@@ -386,3 +413,42 @@ def test_option_dataclass_fixture(
386
413
assert options
387
414
assert hasattr (options , dataclass_attribute )
388
415
assert getattr (options , dataclass_attribute , None ) == expected
416
+
417
+
418
+ @pytest .mark .parametrize (
419
+ list (OptionDataclassTestFixture ._fields ),
420
+ TEST_FIXTURES ,
421
+ ids = [test .test_id for test in TEST_FIXTURES ],
422
+ )
423
+ def test_show_option_pane_fixture (
424
+ monkeypatch : pytest .MonkeyPatch ,
425
+ test_id : str ,
426
+ option_data : t .List [str ],
427
+ tmux_option : str ,
428
+ expected : t .Any ,
429
+ dataclass_attribute : str ,
430
+ server : "Server" ,
431
+ ) -> None :
432
+ """Test Pane.show_option(s)?."""
433
+ session = server .new_session (session_name = "test" )
434
+ window = session .new_window (window_name = "test" )
435
+ pane = window .split_window (attach = False )
436
+
437
+ monkeypatch .setattr (pane , "cmd" , fake_cmd (stdout = option_data ))
438
+
439
+ result = pane .show_option (tmux_option )
440
+
441
+ assert result == expected
442
+
443
+ if expected is None :
444
+ assert (
445
+ result is not None
446
+ ), f"Expected { expected } to be { type (expected )} , got None"
447
+
448
+ if isinstance (expected , dict ):
449
+ assert isinstance (result , dict ), f'Expected dict, got "{ type (result )} "'
450
+
451
+ for k , v in expected .items ():
452
+ assert k in result
453
+
454
+ assert result [k ] == v
0 commit comments