refactor(table): rename tests to match a convention

This commit is contained in:
Andrey Nering
2025-05-23 14:11:10 -03:00
parent 41f23fed58
commit 8ee7e4bfda
19 changed files with 25 additions and 25 deletions
+25 -25
View File
@@ -133,7 +133,7 @@ func TestTableAlignment(t *testing.T) {
{"Tim Tams", "Australia", "No"}, {"Tim Tams", "Australia", "No"},
{"Hobnobs", "UK", "Yes"}, {"Hobnobs", "UK", "Yes"},
} }
t.Run("No border", func(t *testing.T) { t.Run("NoBorder", func(t *testing.T) {
biscuits := New( biscuits := New(
WithHeaders(headers...), WithHeaders(headers...),
WithRows(rows...), WithRows(rows...),
@@ -148,7 +148,7 @@ func TestTableAlignment(t *testing.T) {
}) })
golden.RequireEqual(t, []byte(biscuits.View())) golden.RequireEqual(t, []byte(biscuits.View()))
}) })
t.Run("With border", func(t *testing.T) { t.Run("WithBorder", func(t *testing.T) {
biscuits := New( biscuits := New(
WithHeaders(headers...), WithHeaders(headers...),
WithRows(rows...), WithRows(rows...),
@@ -168,12 +168,12 @@ func TestOverwriteStyles(t *testing.T) {
name string name string
styles Styles styles Styles
}{ }{
{"clear styles", Styles{ {"ClearStyles", Styles{
Selected: lipgloss.NewStyle(), Selected: lipgloss.NewStyle(),
Header: lipgloss.NewStyle(), Header: lipgloss.NewStyle(),
Cell: lipgloss.NewStyle(), Cell: lipgloss.NewStyle(),
}}, }},
{"new styles", Styles{ {"NewStyles", Styles{
Selected: niceMargins.Foreground(lipgloss.Color("68")), Selected: niceMargins.Foreground(lipgloss.Color("68")),
Header: niceMargins, Header: niceMargins,
Cell: niceMargins, Cell: niceMargins,
@@ -198,12 +198,12 @@ func TestSetStyles(t *testing.T) {
name string name string
styles Styles styles Styles
}{ }{
{"empty styles", Styles{ {"EmptyStyles", Styles{
Selected: lipgloss.NewStyle(), Selected: lipgloss.NewStyle(),
Header: lipgloss.NewStyle(), Header: lipgloss.NewStyle(),
Cell: lipgloss.NewStyle(), Cell: lipgloss.NewStyle(),
}}, }},
{"new styles", Styles{ {"NewStyles", Styles{
Selected: niceMargins.Background(lipgloss.Color("68")), Selected: niceMargins.Background(lipgloss.Color("68")),
Header: niceMargins, Header: niceMargins,
Cell: niceMargins, Cell: niceMargins,
@@ -226,7 +226,7 @@ func TestSetStyles(t *testing.T) {
} }
func TestSetStyleFunc(t *testing.T) { func TestSetStyleFunc(t *testing.T) {
t.Run("Clear styles with StyleFunc", func(t *testing.T) { t.Run("ClearStylesWithStyleFunc", func(t *testing.T) {
tb := New( tb := New(
WithHeaders(headers...), WithHeaders(headers...),
WithRows(rows...), WithRows(rows...),
@@ -248,14 +248,14 @@ func TestSetBorder(t *testing.T) {
name string name string
borders []bool borders []bool
}{ }{
{"unset all borders", []bool{false}}, {"UnsetAllBorders", []bool{false}},
// {"set all borders", []bool{true}}, // FIXME(@andreynering): Fix on Lip Gloss. Unneeded extra row. //{"SetAllBorders", []bool{true}}, // FIXME(@andreynering): Fix on Lip Gloss. Unneeded extra row.
{"vertical borders only", []bool{true, false}}, {"VerticalBordersOnly", []bool{true, false}},
{"no top border", []bool{false, true, true}}, {"NoTopBorder", []bool{false, true, true}},
{"no left border", []bool{true, true, true, false}}, {"NoLeftBorder", []bool{true, true, true, false}},
{"row separator and no right border", []bool{true, false, true, true, true}}, {"RowSeparatorAndNoRightBorder", []bool{true, false, true, true, true}},
// {"set row and column separators", []bool{false, false, false, false, true, true}}, // FIXME(@andreynering): Broken style, does this make sense? //{"SetRowAndColumnSeparators", []bool{false, false, false, false, true, true}}, // FIXME(@andreynering): Broken style, does this make sense?
{"invalid number of arguments", []bool{true, false, false, false, false, true, true}}, {"InvalidNumberOfArguments", []bool{true, false, false, false, false, true, true}},
} }
for _, tc := range tests { for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
@@ -651,7 +651,7 @@ func TestModel_View(t *testing.T) {
return New() return New()
}, },
}, },
"Single row and column": { "SingleRowAndColumn": {
modelFunc: func() *Model { modelFunc: func() *Model {
return New( return New(
WithHeaders("Name"), WithHeaders("Name"),
@@ -661,7 +661,7 @@ func TestModel_View(t *testing.T) {
) )
}, },
}, },
"Multiple rows and columns": { "MultipleRowsAndColumns": {
modelFunc: func() *Model { modelFunc: func() *Model {
return New( return New(
WithHeaders("Name", "Country of Origin", "Dunk-able"), WithHeaders("Name", "Country of Origin", "Dunk-able"),
@@ -674,7 +674,7 @@ func TestModel_View(t *testing.T) {
}, },
}, },
// FIXME(@andreynering): Fix this scenario in Lip Gloss // FIXME(@andreynering): Fix this scenario in Lip Gloss
"Extra padding": { "ExtraPadding": {
modelFunc: func() *Model { modelFunc: func() *Model {
s := DefaultStyles() s := DefaultStyles()
s.Header = lipgloss.NewStyle().Padding(2, 2) s.Header = lipgloss.NewStyle().Padding(2, 2)
@@ -693,7 +693,7 @@ func TestModel_View(t *testing.T) {
}, },
skip: true, skip: true,
}, },
"No padding": { "NoPadding": {
modelFunc: func() *Model { modelFunc: func() *Model {
s := DefaultStyles() s := DefaultStyles()
s.Header = lipgloss.NewStyle() s.Header = lipgloss.NewStyle()
@@ -712,7 +712,7 @@ func TestModel_View(t *testing.T) {
}, },
}, },
// FIXME(@andreynering): Fix this scenario in Lip Gloss // FIXME(@andreynering): Fix this scenario in Lip Gloss
"Bordered headers": { "BorderedHeaders": {
modelFunc: func() *Model { modelFunc: func() *Model {
return New( return New(
WithHeaders("Name", "Country of Origin", "Dunk-able"), WithHeaders("Name", "Country of Origin", "Dunk-able"),
@@ -729,7 +729,7 @@ func TestModel_View(t *testing.T) {
skip: true, skip: true,
}, },
// FIXME(@andreynering): Fix this scenario in Lip Gloss // FIXME(@andreynering): Fix this scenario in Lip Gloss
"Bordered cells": { "BorderedCells": {
modelFunc: func() *Model { modelFunc: func() *Model {
return New( return New(
WithHeaders("Name", "Country of Origin", "Dunk-able"), WithHeaders("Name", "Country of Origin", "Dunk-able"),
@@ -746,7 +746,7 @@ func TestModel_View(t *testing.T) {
skip: true, skip: true,
}, },
// FIXME(@andreynering): Fix in Lip Gloss? Potentially add extra empty lines to the bottom of the table. // FIXME(@andreynering): Fix in Lip Gloss? Potentially add extra empty lines to the bottom of the table.
"Manual height greater than rows": { "ManualHeightGreaterThanRows": {
modelFunc: func() *Model { modelFunc: func() *Model {
return New( return New(
WithHeight(15), WithHeight(15),
@@ -760,7 +760,7 @@ func TestModel_View(t *testing.T) {
}, },
}, },
// FIXME(@andreynering): Fix this scenario in Lip Gloss. Should truncate table if height is too small. // FIXME(@andreynering): Fix this scenario in Lip Gloss. Should truncate table if height is too small.
"Manual height less than rows": { "ManualHeightLessThanRows": {
modelFunc: func() *Model { modelFunc: func() *Model {
return New( return New(
WithHeight(2), WithHeight(2),
@@ -774,7 +774,7 @@ func TestModel_View(t *testing.T) {
}, },
skip: true, skip: true,
}, },
"Manual width greater than columns": { "ManualWidthGreaterThanColumns": {
modelFunc: func() *Model { modelFunc: func() *Model {
return New( return New(
WithWidth(80), WithWidth(80),
@@ -788,7 +788,7 @@ func TestModel_View(t *testing.T) {
}, },
}, },
// FIXME(@andreynering): Fix this scenario in Lip Gloss. // FIXME(@andreynering): Fix this scenario in Lip Gloss.
"Manual width less than columns": { "ManualWidthLessThanColumns": {
modelFunc: func() *Model { modelFunc: func() *Model {
return New( return New(
WithWidth(30), WithWidth(30),