-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathrender_bidi_test.go
54 lines (48 loc) · 2.3 KB
/
render_bidi_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package table
import (
"testing"
"github.com/jedib0t/go-pretty/v6/text"
)
func TestTable_Render_BiDiText(t *testing.T) {
// sonar: ignore from here
table := Table{}
table.AppendHeader(Row{"תאריך", "סכום", "מחלקה", "תגים"})
table.AppendRow(Row{"2020-01-01", 5.0, "מחלקה1", []string{"תג1", "תג2"}})
table.AppendRow(Row{"2021-02-01", 5.0, "מחלקה1", []string{"תג1"}})
table.AppendRow(Row{"2022-03-01", 5.0, "מחלקה2", []string{"תג1"}})
table.AppendFooter(Row{"סהכ", 30})
table.SetAutoIndex(true)
compareOutput(t, table.Render(), `
+---+------------+------+--------+-----------+
| | תאריך | סכום | מחלקה | תגים |
+---+------------+------+--------+-----------+
| 1 | 2020-01-01 | 5 | מחלקה1 | [תג1 תג2] |
| 2 | 2021-02-01 | 5 | מחלקה1 | [תג1] |
| 3 | 2022-03-01 | 5 | מחלקה2 | [תג1] |
+---+------------+------+--------+-----------+
| | סהכ | 30 | | |
+---+------------+------+--------+-----------+`)
table.Style().Format.Direction = text.LeftToRight
compareOutput(t, table.Render(), `
+---+------------+------+--------+-----------+
| | תאריך | סכום | מחלקה | תגים |
+---+------------+------+--------+-----------+
| 1 | 2020-01-01 | 5 | מחלקה1 | [תג1 תג2] |
| 2 | 2021-02-01 | 5 | מחלקה1 | [תג1] |
| 3 | 2022-03-01 | 5 | מחלקה2 | [תג1] |
+---+------------+------+--------+-----------+
| | סהכ | 30 | | |
+---+------------+------+--------+-----------+`)
table.Style().Format.Direction = text.RightToLeft
compareOutput(t, table.Render(), `
+---+------------+------+--------+-----------+
| | תאריך | סכום | מחלקה | תגים |
+---+------------+------+--------+-----------+
| 1 | 2020-01-01 | 5 | מחלקה1 | [תג1 תג2] |
| 2 | 2021-02-01 | 5 | מחלקה1 | [תג1] |
| 3 | 2022-03-01 | 5 | מחלקה2 | [תג1] |
+---+------------+------+--------+-----------+
| | סהכ | 30 | | |
+---+------------+------+--------+-----------+`)
// sonar: ignore to here
}