Skip to content

Commit

Permalink
test(table): add ClearRows test to repro nil ptr err
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbunni committed Sep 20, 2024
1 parent 62128fd commit 8067079
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions table/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,24 @@ func TestTableHeightWithOffset(t *testing.T) {
}
}

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 8067079

Please sign in to comment.