From 6c519c8d51dd9157b27968b8fc426d88246bfaec Mon Sep 17 00:00:00 2001 From: Ted Conbeer Date: Thu, 31 Oct 2024 19:09:09 +0000 Subject: [PATCH] fix: add test for null rep --- .../__snapshots__/test_snapshots.ambr | 159 ++++++++++++++++++ .../data_table_null_mixed_cols.py | 22 +++ tests/snapshot_tests/test_snapshots.py | 4 + 3 files changed, 185 insertions(+) create mode 100644 tests/snapshot_tests/snapshot_apps/data_table_null_mixed_cols.py diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr index 25b8d4e..e47cac6 100644 --- a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr +++ b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr @@ -1967,6 +1967,165 @@ ''' # --- +# name: test_datatable_null_mixed_cols + ''' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TableApp + + + + + + + + + +  lane   swimmer               country        time   +  3      Li Zhuhao             China          51.26  +  eight ∅ null France         51.58  +  seven  Tom Shields           United States ∅  +  1      Aleksandr Sadovnikov  Russia         51.84  + ∅  Darren Burns          Scotland       51.84  + + + + + + + + + + + + + + + + + + + + + + + ''' +# --- # name: test_datatable_range_cursor_render ''' diff --git a/tests/snapshot_tests/snapshot_apps/data_table_null_mixed_cols.py b/tests/snapshot_tests/snapshot_apps/data_table_null_mixed_cols.py new file mode 100644 index 0000000..9158364 --- /dev/null +++ b/tests/snapshot_tests/snapshot_apps/data_table_null_mixed_cols.py @@ -0,0 +1,22 @@ +from textual.app import App, ComposeResult +from textual_fastdatatable import ArrowBackend, DataTable + +ROWS = [ + ("lane", "swimmer", "country", "time"), + (3, "Li Zhuhao", "China", 51.26), + ("eight", None, "France", 51.58), + ("seven", "Tom Shields", "United States", None), + (1, "Aleksandr Sadovnikov", "Russia", 51.84), + (None, "Darren Burns", "Scotland", 51.84), +] + + +class TableApp(App): + def compose(self) -> ComposeResult: + backend = ArrowBackend.from_records(ROWS, has_header=True) + yield DataTable(backend=backend, null_rep="[dim]∅ null[/]") + + +app = TableApp() +if __name__ == "__main__": + app.run() diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index 75758bc..ad8a235 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -25,6 +25,10 @@ def test_datatable_no_render_markup(snap_compare: Callable) -> None: assert snap_compare(SNAPSHOT_APPS_DIR / "data_table_no_render_markup.py") +def test_datatable_null_mixed_cols(snap_compare: Callable) -> None: + assert snap_compare(SNAPSHOT_APPS_DIR / "data_table_null_mixed_cols.py") + + def test_datatable_range_cursor_render(snap_compare: Callable) -> None: press = ["right", "down", "shift+right", "shift+down", "shift+down"] assert snap_compare(SNAPSHOT_APPS_DIR / "data_table_range_cursor.py", press=press)