from unittest.mock import patch, MagicMock from src.markdown_table import render_table, TableBlock def test_render_table_uses_text_wrapped_for_cells(): block = TableBlock(headers=["A"], rows=[["hello"]], span=(0, 2)) with patch("src.markdown_table.imgui") as mock_imgui: mock_imgui.TableFlags_ = type("T", (), {"borders": 1, "row_bg": 2, "resizable": 4})() mock_imgui.begin_table.return_value = True mock_imgui.table_next_column = MagicMock() mock_imgui.table_next_row = MagicMock() mock_imgui.table_headers_row = MagicMock() mock_imgui.text_wrapped = MagicMock() mock_imgui.text = MagicMock() mock_imgui.end_table = MagicMock() render_table(block) mock_imgui.text_wrapped.assert_any_call("hello") def test_render_table_uses_text_wrapped_for_headers(): block = TableBlock(headers=["A"], rows=[["hello"]], span=(0, 2)) with patch("src.markdown_table.imgui") as mock_imgui: mock_imgui.TableFlags_ = type("T", (), {"borders": 1, "row_bg": 2, "resizable": 4})() mock_imgui.begin_table.return_value = True mock_imgui.table_next_column = MagicMock() mock_imgui.table_next_row = MagicMock() mock_imgui.table_headers_row = MagicMock() mock_imgui.text_wrapped = MagicMock() mock_imgui.text = MagicMock() mock_imgui.end_table = MagicMock() render_table(block) mock_imgui.text_wrapped.assert_any_call("A") def test_render_table_does_not_use_text_for_cells(): block = TableBlock(headers=["A"], rows=[["hello"]], span=(0, 2)) with patch("src.markdown_table.imgui") as mock_imgui: mock_imgui.TableFlags_ = type("T", (), {"borders": 1, "row_bg": 2, "resizable": 4})() mock_imgui.begin_table.return_value = True mock_imgui.table_next_column = MagicMock() mock_imgui.table_next_row = MagicMock() mock_imgui.table_headers_row = MagicMock() mock_imgui.text_wrapped = MagicMock() mock_imgui.text = MagicMock() mock_imgui.end_table = MagicMock() render_table(block) assert not mock_imgui.text.called, "imgui.text should not be called for table cells"