@@ -189,3 +189,36 @@ def test__update_options():
189189 assert _update_options (d4 , remove_button = True , multiple = True ) == d4
190190 assert _update_options (d4 , remove_button = True , multiple = False ) == d4
191191 assert _update_options (d4 , remove_button = False , multiple = False ) == d4
192+
193+
194+ def test_tooltip_options ():
195+ """Test that tooltip renders options as bsOptions attribute."""
196+ # Test with options parameter
197+ options_dict : dict [str , object ] = {"offset" : [0 , 100 ]}
198+ t = ui .tooltip (
199+ ui .input_action_button ("btn" , "Test" ),
200+ "A message" ,
201+ id = "test_tooltip" ,
202+ placement = "right" ,
203+ options = options_dict ,
204+ )
205+
206+ t_str = str (t )
207+
208+ # Should contain bsOptions attribute with JSON-encoded options
209+ assert "bsoptions" in t_str .lower (), "bsOptions attribute should be present"
210+ # Check that the JSON content is present (HTML entities are encoded, so " becomes ")
211+ assert ""offset"" in t_str and (
212+ "[0, 100]" in t_str or "[0,100]" in t_str
213+ ), "Options should be JSON-encoded with offset value"
214+
215+ # Test without options parameter
216+ t2 = ui .tooltip (
217+ ui .input_action_button ("btn2" , "Test2" ),
218+ "Another message" ,
219+ id = "test_tooltip2" ,
220+ )
221+
222+ t2_str = str (t2 )
223+ # Should still render properly
224+ assert "bslib-tooltip" in t2_str , "Tooltip should render without options"
0 commit comments