Private
Public Access
0
0

fix(markdown): revert table to simple form with text_wrapped + add regression tests

This commit is contained in:
Conductor
2026-06-03 17:31:50 -04:00
parent 7aa40755ce
commit d15fdcdb05
3 changed files with 105 additions and 9 deletions
+44
View File
@@ -0,0 +1,44 @@
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"