Skip to content

Commit

Permalink
table: SupressTrailingSpaces -> SuppressTrailingSpaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jedib0t committed Jan 4, 2024
1 parent 8dba2e0 commit e8ba334
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 40 deletions.
42 changes: 6 additions & 36 deletions table/render_test.go
Expand Up @@ -1176,7 +1176,7 @@ func TestTable_Render_WidthEnforcer(t *testing.T) {
+------+----------------------+------------------+----------------------------+`)
}

func TestTable_Render_SupressTrailingSpaces(t *testing.T) {
func TestTable_Render_SuppressTrailingSpaces(t *testing.T) {
tw := NewWriter()
tw.AppendHeader(testHeader2)
tw.AppendRows([]Row{
Expand All @@ -1186,37 +1186,10 @@ func TestTable_Render_SupressTrailingSpaces(t *testing.T) {
{"R123", "Some big name here and it's pretty big", "2021-04-19 13:37", "Abcdefghijklmnopqrstuvwxyz"},
{"R123", "Small name", "2021-04-19 13:37", "Abcdefghijklmnopqrstuvwxyz"},
})
tw.SuppressTrailingSpaces()

t.Run("borders and separators", func(t *testing.T) {
tw.Style().Options = OptionsDefault
compareOutput(t, tw.Render(), `
+------+----------------------------------------+------------------+----------------------------+
| ID | TEXT1 | DATE | TEXT2 |
+------+----------------------------------------+------------------+----------------------------+
| U2 | Hey | 2021-04-19 13:37 | Yuh yuh yuh |
| S12 | Uhhhh | 2021-04-19 13:37 | Some dummy data here |
| R123 | Lobsters | 2021-04-19 13:37 | I like lobsters |
| R123 | Some big name here and it's pretty big | 2021-04-19 13:37 | Abcdefghijklmnopqrstuvwxyz |
| R123 | Small name | 2021-04-19 13:37 | Abcdefghijklmnopqrstuvwxyz |
+------+----------------------------------------+------------------+----------------------------+`)
})

t.Run("no borders and separators", func(t *testing.T) {
tw.Style().Options = OptionsNoBordersAndSeparators
compareOutput(t, tw.Render(), `
ID TEXT1 DATE TEXT2
U2 Hey 2021-04-19 13:37 Yuh yuh yuh
S12 Uhhhh 2021-04-19 13:37 Some dummy data here
R123 Lobsters 2021-04-19 13:37 I like lobsters
R123 Some big name here and it's pretty big 2021-04-19 13:37 Abcdefghijklmnopqrstuvwxyz
R123 Small name 2021-04-19 13:37 Abcdefghijklmnopqrstuvwxyz `)
})

tw.SupressTrailingSpaces()

t.Run("borders and separators suppressed spaces", func(t *testing.T) {
tw.Style().Options = OptionsDefault
compareOutput(t, tw.Render(), `
tw.Style().Options = OptionsDefault
compareOutput(t, tw.Render(), `
+------+----------------------------------------+------------------+----------------------------+
| ID | TEXT1 | DATE | TEXT2 |
+------+----------------------------------------+------------------+----------------------------+
Expand All @@ -1226,16 +1199,13 @@ func TestTable_Render_SupressTrailingSpaces(t *testing.T) {
| R123 | Some big name here and it's pretty big | 2021-04-19 13:37 | Abcdefghijklmnopqrstuvwxyz |
| R123 | Small name | 2021-04-19 13:37 | Abcdefghijklmnopqrstuvwxyz |
+------+----------------------------------------+------------------+----------------------------+`)
})

t.Run("no borders and separators suppressed spaces", func(t *testing.T) {
tw.Style().Options = OptionsNoBordersAndSeparators
compareOutput(t, tw.Render(), `
tw.Style().Options = OptionsNoBordersAndSeparators
compareOutput(t, tw.Render(), `
ID TEXT1 DATE TEXT2
U2 Hey 2021-04-19 13:37 Yuh yuh yuh
S12 Uhhhh 2021-04-19 13:37 Some dummy data here
R123 Lobsters 2021-04-19 13:37 I like lobsters
R123 Some big name here and it's pretty big 2021-04-19 13:37 Abcdefghijklmnopqrstuvwxyz
R123 Small name 2021-04-19 13:37 Abcdefghijklmnopqrstuvwxyz`)
})
}
5 changes: 2 additions & 3 deletions table/table.go
Expand Up @@ -300,9 +300,8 @@ func (t *Table) SuppressEmptyColumns() {
t.suppressEmptyColumns = true
}

// SupressTrailingSpaces removes all trailing spaces from the end of the last column
// this is useful when OptionsNoBordersAndSeparators is used
func (t *Table) SupressTrailingSpaces() {
// SuppressTrailingSpaces removes all trailing spaces from the output.
func (t *Table) SuppressTrailingSpaces() {
t.supressTrailingSpaces = true
}

Expand Down
2 changes: 1 addition & 1 deletion table/writer.go
Expand Up @@ -33,7 +33,7 @@ type Writer interface {
SortBy(sortBy []SortBy)
Style() *Style
SuppressEmptyColumns()
SupressTrailingSpaces()
SuppressTrailingSpaces()

// deprecated; in favor of Style().HTML.CSSClass
SetHTMLCSSClass(cssClass string)
Expand Down

0 comments on commit e8ba334

Please sign in to comment.