@@ -3341,3 +3341,40 @@ def run_alert():
33413341
33423342 assert len (exceptions ) == 1
33433343 assert "another thread holds terminal_lock" in str (exceptions [0 ])
3344+
3345+
3346+ def test_bottom_toolbar (base_app ):
3347+ from prompt_toolkit .formatted_text import ANSI
3348+
3349+ # Test when both are empty
3350+ base_app .formatted_completions = ''
3351+ base_app .completion_hint = ''
3352+ assert base_app ._bottom_toolbar () is None
3353+
3354+ # Test when formatted_completions is set
3355+ text = 'completions'
3356+ base_app .formatted_completions = text + '\n '
3357+ base_app .completion_hint = ''
3358+ result = base_app ._bottom_toolbar ()
3359+ assert isinstance (result , ANSI )
3360+
3361+ # Test when completion_hint is set
3362+ hint = 'hint'
3363+ base_app .formatted_completions = ''
3364+ base_app .completion_hint = hint + ' '
3365+ result = base_app ._bottom_toolbar ()
3366+ assert isinstance (result , ANSI )
3367+
3368+ # Test prioritization and rstrip
3369+ with mock .patch ('cmd2.cmd2.ANSI' , wraps = ANSI ) as mock_ansi :
3370+ # formatted_completions takes precedence
3371+ base_app .formatted_completions = 'formatted\n '
3372+ base_app .completion_hint = 'hint'
3373+ base_app ._bottom_toolbar ()
3374+ mock_ansi .assert_called_with ('formatted' )
3375+
3376+ # completion_hint used when formatted_completions is empty
3377+ base_app .formatted_completions = ''
3378+ base_app .completion_hint = 'hint '
3379+ base_app ._bottom_toolbar ()
3380+ mock_ansi .assert_called_with ('hint' )
0 commit comments