diff --git a/table/render_test.go b/table/render_test.go index b2400e4..e12f297 100644 --- a/table/render_test.go +++ b/table/render_test.go @@ -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{ @@ -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 | +------+----------------------------------------+------------------+----------------------------+ @@ -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`) - }) } diff --git a/table/table.go b/table/table.go index 42e7129..4b3f21d 100644 --- a/table/table.go +++ b/table/table.go @@ -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 } diff --git a/table/writer.go b/table/writer.go index 7b57b3e..f993d86 100644 --- a/table/writer.go +++ b/table/writer.go @@ -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)