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