-
Notifications
You must be signed in to change notification settings - Fork 119
/
render_html_test.go
107 lines (99 loc) · 2.66 KB
/
render_html_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package list
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestList_RenderHTML(t *testing.T) {
lw := NewWriter()
lw.AppendItem(testItem1)
lw.Indent()
lw.AppendItems(testItems2)
lw.Indent()
lw.AppendItems(testItems3)
lw.UnIndent()
lw.UnIndent()
lw.AppendItem(testItem4)
lw.Indent()
lw.AppendItem(testItem5)
lw.SetHTMLCSSClass(testCSSClass)
expectedOut := `<ul class="test-css-class">
<li>Game Of Thrones</li>
<ul class="test-css-class-1">
<li>Winter</li>
<li>Is</li>
<li>Coming</li>
<ul class="test-css-class-2">
<li>This</li>
<li>Is</li>
<li>Known</li>
</ul>
</ul>
<li>The Dark Tower</li>
<ul class="test-css-class-1">
<li>The Gunslinger</li>
</ul>
</ul>`
assert.Equal(t, expectedOut, lw.RenderHTML())
}
func TestList_RenderHTML_Complex(t *testing.T) {
lw := NewWriter()
lw.AppendItem("The Houses of Westeros")
lw.Indent()
lw.AppendItem("The Starks of Winterfell")
lw.Indent()
lw.AppendItem("Eddard Stark")
lw.Indent()
lw.AppendItems([]interface{}{"Robb Stark", "Sansa Stark", "Arya Stark", "Bran Stark", "Rickon Stark"})
lw.UnIndent()
lw.AppendItems([]interface{}{"Lyanna Stark", "Benjen Stark"})
lw.UnIndent()
lw.AppendItem("The Targaryens of Dragonstone")
lw.Indent()
lw.AppendItem("Aerys Targaryen")
lw.Indent()
lw.AppendItems([]interface{}{"Rhaegar Targaryen", "Viserys Targaryen", "Daenerys Targaryen"})
lw.UnIndent()
lw.UnIndent()
lw.AppendItem("The Lannisters of Lannisport")
lw.Indent()
lw.AppendItem("Tywin Lannister")
lw.Indent()
lw.AppendItems([]interface{}{"Cersei Lannister", "Jaime Lannister", "Tyrion Lannister"})
expectedOut := `<ul class="go-pretty-table">
<li>The Houses of Westeros</li>
<ul class="go-pretty-table-1">
<li>The Starks of Winterfell</li>
<ul class="go-pretty-table-2">
<li>Eddard Stark</li>
<ul class="go-pretty-table-3">
<li>Robb Stark</li>
<li>Sansa Stark</li>
<li>Arya Stark</li>
<li>Bran Stark</li>
<li>Rickon Stark</li>
</ul>
<li>Lyanna Stark</li>
<li>Benjen Stark</li>
</ul>
<li>The Targaryens of Dragonstone</li>
<ul class="go-pretty-table-2">
<li>Aerys Targaryen</li>
<ul class="go-pretty-table-3">
<li>Rhaegar Targaryen</li>
<li>Viserys Targaryen</li>
<li>Daenerys Targaryen</li>
</ul>
</ul>
<li>The Lannisters of Lannisport</li>
<ul class="go-pretty-table-2">
<li>Tywin Lannister</li>
<ul class="go-pretty-table-3">
<li>Cersei Lannister</li>
<li>Jaime Lannister</li>
<li>Tyrion Lannister</li>
</ul>
</ul>
</ul>
</ul>`
assert.Equal(t, expectedOut, lw.RenderHTML())
}