-
Notifications
You must be signed in to change notification settings - Fork 234
/
Copy pathborders_test.go
96 lines (89 loc) · 2.26 KB
/
borders_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
package lipgloss
import "testing"
func TestStyle_GetBorderSizes(t *testing.T) {
tests := []struct {
name string
style Style
wantX int
wantY int
}{
{
name: "Default style",
style: NewStyle(),
wantX: 0,
wantY: 0,
},
{
name: "Border(NormalBorder())",
style: NewStyle().Border(NormalBorder()),
wantX: 2,
wantY: 2,
},
{
name: "Border(NormalBorder(), true)",
style: NewStyle().Border(NormalBorder(), true),
wantX: 2,
wantY: 2,
},
{
name: "Border(NormalBorder(), true, false)",
style: NewStyle().Border(NormalBorder(), true, false),
wantX: 0,
wantY: 2,
},
{
name: "Border(NormalBorder(), true, true, false)",
style: NewStyle().Border(NormalBorder(), true, true, false),
wantX: 2,
wantY: 1,
},
{
name: "Border(NormalBorder(), true, true, false, false)",
style: NewStyle().Border(NormalBorder(), true, true, false, false),
wantX: 1,
wantY: 1,
},
{
name: "BorderTop(true).BorderStyle(NormalBorder())",
style: NewStyle().BorderTop(true).BorderStyle(NormalBorder()),
wantX: 0,
wantY: 1,
},
{
name: "BorderStyle(NormalBorder())",
style: NewStyle().BorderStyle(NormalBorder()),
wantX: 2,
wantY: 2,
},
{
name: "Custom BorderStyle",
style: NewStyle().BorderStyle(Border{Left: "123456789"}),
wantX: 1, // left and right borders are laid out vertically, one rune per row
wantY: 0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotX := tt.style.GetHorizontalBorderSize()
if gotX != tt.wantX {
t.Errorf("Style.GetHorizontalBorderSize() got %d, want %d", gotX, tt.wantX)
}
gotY := tt.style.GetVerticalBorderSize()
if gotY != tt.wantY {
t.Errorf("Style.GetVerticalBorderSize() got %d, want %d", gotY, tt.wantY)
}
gotX = tt.style.GetHorizontalFrameSize()
if gotX != tt.wantX {
t.Errorf("Style.GetHorizontalFrameSize() got %d, want %d", gotX, tt.wantX)
}
gotY = tt.style.GetVerticalFrameSize()
if gotY != tt.wantY {
t.Errorf("Style.GetVerticalFrameSize() got %d, want %d", gotY, tt.wantY)
}
gotX, gotY = tt.style.GetFrameSize()
if gotX != tt.wantX || gotY != tt.wantY {
t.Errorf("Style.GetFrameSize() got (%d, %d), want (%d, %d)", gotX, gotY, tt.wantX, tt.wantY)
}
})
}
}