From 78e9bc479cd27736c9cdbabd0e7a9bbe68ec88a4 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Wed, 28 May 2025 17:35:14 -0300 Subject: [PATCH] test: re-enable tests and record golden files after fixes on lipgloss https://github.com/charmbracelet/lipgloss/pull/526 --- table/table_test.go | 15 ++--------- .../TestModel_View/BorderedCells.golden | 11 ++++++++ .../TestModel_View/BorderedHeaders.golden | 9 +++++++ .../TestModel_View/ExtraPadding.golden | 19 ++++++++++++++ .../ManualHeightLessThanRows.golden | 2 ++ .../ManualWidthGreaterThanColumns.golden | 14 +++++------ .../ManualWidthLessThanColumns.golden | 10 ++++++++ .../RowSeparatorAndNoRightBorder.golden | 25 +++++++------------ .../TestSetBorder/SetAllBorders.golden | 9 +++++++ .../SetRowAndColumnSeparators.golden | 9 +++++++ .../TestSetBorder/UnsetAllBorders.golden | 4 +-- 11 files changed, 89 insertions(+), 38 deletions(-) create mode 100644 table/testdata/TestModel_View/BorderedCells.golden create mode 100644 table/testdata/TestModel_View/BorderedHeaders.golden create mode 100644 table/testdata/TestModel_View/ExtraPadding.golden create mode 100644 table/testdata/TestModel_View/ManualHeightLessThanRows.golden create mode 100644 table/testdata/TestModel_View/ManualWidthLessThanColumns.golden create mode 100644 table/testdata/TestSetBorder/SetAllBorders.golden create mode 100644 table/testdata/TestSetBorder/SetRowAndColumnSeparators.golden diff --git a/table/table_test.go b/table/table_test.go index 2358c69..fe2cbc7 100644 --- a/table/table_test.go +++ b/table/table_test.go @@ -249,12 +249,12 @@ func TestSetBorder(t *testing.T) { borders []bool }{ {"UnsetAllBorders", []bool{false}}, - //{"SetAllBorders", []bool{true}}, // FIXME(@andreynering): Fix on Lip Gloss. Unneeded extra row. + {"SetAllBorders", []bool{true}}, {"VerticalBordersOnly", []bool{true, false}}, {"NoTopBorder", []bool{false, true, true}}, {"NoLeftBorder", []bool{true, true, true, false}}, {"RowSeparatorAndNoRightBorder", []bool{true, false, true, true, true}}, - //{"SetRowAndColumnSeparators", []bool{false, false, false, false, true, true}}, // FIXME(@andreynering): Broken style, does this make sense? + {"SetRowAndColumnSeparators", []bool{false, false, false, false, true, true}}, {"InvalidNumberOfArguments", []bool{true, false, false, false, false, true, true}}, } for _, tc := range tests { @@ -673,7 +673,6 @@ func TestModel_View(t *testing.T) { ) }, }, - // FIXME(@andreynering): Fix this scenario in Lip Gloss "ExtraPadding": { modelFunc: func() *Model { s := DefaultStyles() @@ -681,7 +680,6 @@ func TestModel_View(t *testing.T) { s.Cell = lipgloss.NewStyle().Padding(2, 2) return New( - WithHeight(10), WithHeaders("Name", "Country of Origin", "Dunk-able"), WithRows( []string{"Chocolate Digestives", "UK", "Yes"}, @@ -691,7 +689,6 @@ func TestModel_View(t *testing.T) { WithStyles(s), ) }, - skip: true, }, "NoPadding": { modelFunc: func() *Model { @@ -711,7 +708,6 @@ func TestModel_View(t *testing.T) { ) }, }, - // FIXME(@andreynering): Fix this scenario in Lip Gloss "BorderedHeaders": { modelFunc: func() *Model { return New( @@ -726,9 +722,7 @@ func TestModel_View(t *testing.T) { }), ) }, - skip: true, }, - // FIXME(@andreynering): Fix this scenario in Lip Gloss "BorderedCells": { modelFunc: func() *Model { return New( @@ -743,7 +737,6 @@ func TestModel_View(t *testing.T) { }), ) }, - skip: true, }, // FIXME(@andreynering): Fix in Lip Gloss? Potentially add extra empty lines to the bottom of the table. "ManualHeightGreaterThanRows": { @@ -759,7 +752,6 @@ func TestModel_View(t *testing.T) { ) }, }, - // FIXME(@andreynering): Fix this scenario in Lip Gloss. Should truncate table if height is too small. "ManualHeightLessThanRows": { modelFunc: func() *Model { return New( @@ -772,7 +764,6 @@ func TestModel_View(t *testing.T) { ), ) }, - skip: true, }, "ManualWidthGreaterThanColumns": { modelFunc: func() *Model { @@ -787,7 +778,6 @@ func TestModel_View(t *testing.T) { ) }, }, - // FIXME(@andreynering): Fix this scenario in Lip Gloss. "ManualWidthLessThanColumns": { modelFunc: func() *Model { return New( @@ -800,7 +790,6 @@ func TestModel_View(t *testing.T) { ), ) }, - skip: true, }, } diff --git a/table/testdata/TestModel_View/BorderedCells.golden b/table/testdata/TestModel_View/BorderedCells.golden new file mode 100644 index 0000000..237b819 --- /dev/null +++ b/table/testdata/TestModel_View/BorderedCells.golden @@ -0,0 +1,11 @@ +┌────────────────────────────────────────────────────┐ +│ Name   Country of Origin  Dunk-able │ +├────────────────────────────────────────────────────┤ +│ Chocolate Digestives  UK   Yes  │ +│┌────────────────────┐┌─────────────────┐┌─────────┐│ +││Tim Tams ││Australia ││No ││ +│└────────────────────┘└─────────────────┘└─────────┘│ +│┌────────────────────┐┌─────────────────┐┌─────────┐│ +││Hobnobs ││UK ││Yes ││ +│└────────────────────┘└─────────────────┘└─────────┘│ +└────────────────────────────────────────────────────┘ \ No newline at end of file diff --git a/table/testdata/TestModel_View/BorderedHeaders.golden b/table/testdata/TestModel_View/BorderedHeaders.golden new file mode 100644 index 0000000..5698736 --- /dev/null +++ b/table/testdata/TestModel_View/BorderedHeaders.golden @@ -0,0 +1,9 @@ +┌────────────────────────────────────────────────────┐ +│┌────────────────────┐┌─────────────────┐┌─────────┐│ +││Name ││Country of Origin││Dunk-able││ +│└────────────────────┘└─────────────────┘└─────────┘│ +├────────────────────────────────────────────────────┤ +│ Chocolate Digestives  UK   Yes  │ +│ Tim Tams   Australia   No  │ +│ Hobnobs   UK   Yes  │ +└────────────────────────────────────────────────────┘ \ No newline at end of file diff --git a/table/testdata/TestModel_View/ExtraPadding.golden b/table/testdata/TestModel_View/ExtraPadding.golden new file mode 100644 index 0000000..7aa3c3b --- /dev/null +++ b/table/testdata/TestModel_View/ExtraPadding.golden @@ -0,0 +1,19 @@ +┌──────────────────────────────────────────────────────────┐ +│ │ +│ │ +│  Name     Country of Origin    Dunk-able  │ +│ │ +│ │ +├──────────────────────────────────────────────────────────┤ +│ Chocolate Digestives   UK   Yes  │ +│ │ +│ │ +│  Tim Tams     Australia     No   │ +│ │ +│ │ +│ │ +│ │ +│  Hobnobs     UK     Yes   │ +│ │ +│ │ +└──────────────────────────────────────────────────────────┘ \ No newline at end of file diff --git a/table/testdata/TestModel_View/ManualHeightLessThanRows.golden b/table/testdata/TestModel_View/ManualHeightLessThanRows.golden new file mode 100644 index 0000000..8573f95 --- /dev/null +++ b/table/testdata/TestModel_View/ManualHeightLessThanRows.golden @@ -0,0 +1,2 @@ +┌────────────────────────────────────────────────────┐ +│ Name   Country of Origin  Dunk-able │ \ No newline at end of file diff --git a/table/testdata/TestModel_View/ManualWidthGreaterThanColumns.golden b/table/testdata/TestModel_View/ManualWidthGreaterThanColumns.golden index fc0f821..45d3d96 100644 --- a/table/testdata/TestModel_View/ManualWidthGreaterThanColumns.golden +++ b/table/testdata/TestModel_View/ManualWidthGreaterThanColumns.golden @@ -1,7 +1,7 @@ -┌─────────────────────────────────────────────────────────────────────────────── -│ Name   Country of Origin   Dunk-able  -├─────────────────────────────────────────────────────────────────────────────── -│ Chocolate Digestives   UK   Yes  -│ Tim Tams   Australia   No  -│ Hobnobs   UK   Yes  -└─────────────────────────────────────────────────────────────────────────────── \ No newline at end of file +┌──────────────────────────────────────────────────────────────────────────────┐ +│ Name   Country of Origin   Dunk-able  │ +├──────────────────────────────────────────────────────────────────────────────┤ +│ Chocolate Digestives   UK   Yes  │ +│ Tim Tams   Australia   No  │ +│ Hobnobs   UK   Yes  │ +└──────────────────────────────────────────────────────────────────────────────┘ \ No newline at end of file diff --git a/table/testdata/TestModel_View/ManualWidthLessThanColumns.golden b/table/testdata/TestModel_View/ManualWidthLessThanColumns.golden new file mode 100644 index 0000000..b54c17d --- /dev/null +++ b/table/testdata/TestModel_View/ManualWidthLessThanColumns.golden @@ -0,0 +1,10 @@ +┌────────────────────────────┐ +│ Name   Count…  Dunk-a… │ +├────────────────────────────┤ +│ Chocolate  UK   Yes  │ +│ Digestive  │ +│ s  │ +│ Tim Tams   Austra  No  │ +│  lia  │ +│ Hobnobs   UK   Yes  │ +└────────────────────────────┘ \ No newline at end of file diff --git a/table/testdata/TestSetBorder/RowSeparatorAndNoRightBorder.golden b/table/testdata/TestSetBorder/RowSeparatorAndNoRightBorder.golden index 3fcc629..b05b56a 100644 --- a/table/testdata/TestSetBorder/RowSeparatorAndNoRightBorder.golden +++ b/table/testdata/TestSetBorder/RowSeparatorAndNoRightBorder.golden @@ -1,16 +1,9 @@ -┌──────────────────────────────────────────── -│ Rank  City   Country   Population  -├──────────────────────────────────────────── -│ 1   Tokyo   Japan   37,274,000  -├────────────────────────────────────────────┤ -│ 2   Delhi   India   32,065,760  -├────────────────────────────────────────────┤ -│ 3   Shanghai   China   28,516,904  -├────────────────────────────────────────────┤ -│ 4   Dhaka   Bangladesh  22,478,116  -├────────────────────────────────────────────┤ -│ 5   São Paulo   Brazil   22,429,800  -├────────────────────────────────────────────┤ -│ …   …   …   …  -├────────────────────────────────────────────┤ -└──────────────────────────────────────────── \ No newline at end of file +┌──────────────────────────────────────────── +│ Rank  City   Country   Population  +├──────────────────────────────────────────── +│ 1   Tokyo   Japan   37,274,000  +├──────────────────────────────────────────── +│ 2   Delhi   India   32,065,760  +├──────────────────────────────────────────── +│ …   …   …   …  +└──────────────────────────────────────────── \ No newline at end of file diff --git a/table/testdata/TestSetBorder/SetAllBorders.golden b/table/testdata/TestSetBorder/SetAllBorders.golden new file mode 100644 index 0000000..93f7321 --- /dev/null +++ b/table/testdata/TestSetBorder/SetAllBorders.golden @@ -0,0 +1,9 @@ +┌──────┬──────────────┬────────────┬────────────┐ +│ Rank │ City  │ Country  │ Population │ +├──────┼──────────────┼────────────┼────────────┤ +│ 1  │ Tokyo  │ Japan  │ 37,274,000 │ +├──────┼──────────────┼────────────┼────────────┤ +│ 2  │ Delhi  │ India  │ 32,065,760 │ +├──────┼──────────────┼────────────┼────────────┤ +│ …  │ …  │ …  │ …  │ +└──────┴──────────────┴────────────┴────────────┘ \ No newline at end of file diff --git a/table/testdata/TestSetBorder/SetRowAndColumnSeparators.golden b/table/testdata/TestSetBorder/SetRowAndColumnSeparators.golden new file mode 100644 index 0000000..b52328d --- /dev/null +++ b/table/testdata/TestSetBorder/SetRowAndColumnSeparators.golden @@ -0,0 +1,9 @@ + Rank │ City  │ Country  │ Population  +──────┼──────────────┼────────────┼──────────── + 1  │ Tokyo  │ Japan  │ 37,274,000  +──────┼──────────────┼────────────┼──────────── + 2  │ Delhi  │ India  │ 32,065,760  +──────┼──────────────┼────────────┼──────────── + 3  │ Shanghai  │ China  │ 28,516,904  +──────┼──────────────┼────────────┼──────────── + …  │ …  │ …  │ …  \ No newline at end of file diff --git a/table/testdata/TestSetBorder/UnsetAllBorders.golden b/table/testdata/TestSetBorder/UnsetAllBorders.golden index d86fb56..940f92c 100644 --- a/table/testdata/TestSetBorder/UnsetAllBorders.golden +++ b/table/testdata/TestSetBorder/UnsetAllBorders.golden @@ -6,5 +6,5 @@  4   Dhaka   Bangladesh  22,478,116   5   São Paulo   Brazil   22,429,800   6   Mexico City   Mexico   22,085,140  - …   …   …   …  - \ No newline at end of file + 7   Cairo   Egypt   21,750,020  + …   …   …   …  \ No newline at end of file