Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbunni committed Oct 3, 2024
2 parents 55b06d5 + b08e7e4 commit 09e9286
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func New() *Table {

// ClearRows clears the table rows.
func (t *Table) ClearRows() *Table {
t.data = nil
t.data = NewStringData()
return t
}

Expand Down
18 changes: 18 additions & 0 deletions table/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,24 @@ func TestStyleFunc(t *testing.T) {
golden.RequireEqual(t, []byte(table.String()))
}

func TestClearRows(t *testing.T) {
defer func() {
if r := recover(); r != nil {
t.Fatalf("had to recover: %v", r)
}
}()

table := New().
Border(lipgloss.NormalBorder()).
Headers("LANGUAGE", "FORMAL", "INFORMAL").
Row("Chinese", "Nǐn hǎo", "Nǐ hǎo")
table.ClearRows()
table.Row("French", "Bonjour", "Salut")

// String() will try to get the rows from table.data
table.String()
}

func debug(s string) string {
return strings.ReplaceAll(s, " ", ".")
}
Expand Down

0 comments on commit 09e9286

Please sign in to comment.