@@ -90,40 +90,45 @@ type S = lipgloss.Style
90
90
91
91
// TestStyle validates most of the Get, Set and Unset methods.
92
92
func TestStyle (t * testing.T ) {
93
+ g := lipgloss .Color ("#0f0" )
94
+ r := lipgloss .Color ("#f00" )
95
+ b := lipgloss .Color ("#00f" )
96
+ w := lipgloss .Color ("#fff" )
97
+
93
98
td := []struct {
94
99
changeStyle func (S ) S
95
100
repr string
96
101
}{
97
102
{func (s S ) S { return s .Align (0.5 ) }, `align: 0.5;` },
98
- {func (s S ) S { return s .Background (lipgloss . Color ( "#0f0" ) ) }, `background: #0f0;` },
103
+ {func (s S ) S { return s .Background (g ) }, `background: #0f0;` },
99
104
{func (s S ) S { return s .Blink (true ) }, `blink: true;` },
100
105
{func (s S ) S { return s .Bold (true ) }, `bold: true;` },
101
106
{func (s S ) S { return s .BorderBottom (true ) }, `border-bottom: true;` },
102
- {func (s S ) S { return s .BorderBottomBackground (lipgloss . Color ( "#0f0" ) ) }, `border-bottom-background: #0f0;` },
103
- {func (s S ) S { return s .BorderBottomForeground (lipgloss . Color ( "#0f0" ) ) }, `border-bottom-foreground: #0f0;` },
107
+ {func (s S ) S { return s .BorderBottomBackground (g ) }, `border-bottom-background: #0f0;` },
108
+ {func (s S ) S { return s .BorderBottomForeground (g ) }, `border-bottom-foreground: #0f0;` },
104
109
{func (s S ) S { return s .BorderLeft (true ) }, `border-left: true;` },
105
- {func (s S ) S { return s .BorderLeftBackground (lipgloss . Color ( "#0f0" ) ) }, `border-left-background: #0f0;` },
106
- {func (s S ) S { return s .BorderLeftForeground (lipgloss . Color ( "#0f0" ) ) }, `border-left-foreground: #0f0;` },
110
+ {func (s S ) S { return s .BorderLeftBackground (g ) }, `border-left-background: #0f0;` },
111
+ {func (s S ) S { return s .BorderLeftForeground (g ) }, `border-left-foreground: #0f0;` },
107
112
{func (s S ) S { return s .BorderRight (true ) }, `border-right: true;` },
108
- {func (s S ) S { return s .BorderRightBackground (lipgloss . Color ( "#0f0" ) ) }, `border-right-background: #0f0;` },
109
- {func (s S ) S { return s .BorderRightForeground (lipgloss . Color ( "#0f0" ) ) }, `border-right-foreground: #0f0;` },
113
+ {func (s S ) S { return s .BorderRightBackground (g ) }, `border-right-background: #0f0;` },
114
+ {func (s S ) S { return s .BorderRightForeground (g ) }, `border-right-foreground: #0f0;` },
110
115
{func (s S ) S {
111
116
return s .BorderStyle (lipgloss.Border {"a" , "b" , "c" , "d" , "e" , "f" , "g" , "h" })
112
117
}, `border-style: border("a","b","c","d","e","f","g","h");` },
113
118
{func (s S ) S { return s .BorderTop (true ) }, `border-top: true;` },
114
- {func (s S ) S { return s .BorderTopBackground (lipgloss . Color ( "#0f0" ) ) }, `border-top-background: #0f0;` },
115
- {func (s S ) S { return s .BorderTopForeground (lipgloss . Color ( "#0f0" ) ) }, `border-top-foreground: #0f0;` },
119
+ {func (s S ) S { return s .BorderTopBackground (g ) }, `border-top-background: #0f0;` },
120
+ {func (s S ) S { return s .BorderTopForeground (g ) }, `border-top-foreground: #0f0;` },
116
121
{func (s S ) S {
117
122
return s .Border (lipgloss.Border {"a" , "b" , "c" , "d" , "e" , "f" , "g" , "h" }, true )
118
123
}, `border-bottom: true; border-left: true; border-right: true; ` +
119
124
`border-style: border("a","b","c","d","e","f","g","h"); ` +
120
125
`border-top: true;` },
121
- {func (s S ) S { return s .BorderBackground (lipgloss . Color ( "#0f0" ) ) }, `border-bottom-background: #0f0; border-left-background: #0f0; border-right-background: #0f0; border-top-background: #0f0;` },
122
- {func (s S ) S { return s .BorderForeground (lipgloss . Color ( "#0f0" ) ) }, `border-bottom-foreground: #0f0; border-left-foreground: #0f0; border-right-foreground: #0f0; border-top-foreground: #0f0;` },
126
+ {func (s S ) S { return s .BorderBackground (g ) }, `border-bottom-background: #0f0; border-left-background: #0f0; border-right-background: #0f0; border-top-background: #0f0;` },
127
+ {func (s S ) S { return s .BorderForeground (g ) }, `border-bottom-foreground: #0f0; border-left-foreground: #0f0; border-right-foreground: #0f0; border-top-foreground: #0f0;` },
123
128
124
129
{func (s S ) S { return s .ColorWhitespace (true ) }, `color-whitespace: true;` },
125
130
{func (s S ) S { return s .Faint (true ) }, `faint: true;` },
126
- {func (s S ) S { return s .Foreground (lipgloss . Color ( "#0f0" ) ) }, `foreground: #0f0;` },
131
+ {func (s S ) S { return s .Foreground (g ) }, `foreground: #0f0;` },
127
132
{func (s S ) S { return s .Height (3 ) }, `height: 3;` },
128
133
{func (s S ) S { return s .Inline (true ) }, `inline: true;` },
129
134
{func (s S ) S { return s .Italic (true ) }, `italic: true;` },
@@ -132,7 +137,7 @@ func TestStyle(t *testing.T) {
132
137
{func (s S ) S { return s .MarginLeft (3 ) }, `margin-left: 3;` },
133
138
{func (s S ) S { return s .MarginRight (3 ) }, `margin-right: 3;` },
134
139
{func (s S ) S { return s .MarginTop (3 ) }, `margin-top: 3;` },
135
- {func (s S ) S { return s .MarginBackground (lipgloss . Color ( "#0f0" ) ) }, `margin-background: #0f0;` },
140
+ {func (s S ) S { return s .MarginBackground (g ) }, `margin-background: #0f0;` },
136
141
{func (s S ) S { return s .MaxHeight (3 ) }, `max-height: 3;` },
137
142
{func (s S ) S { return s .MaxWidth (3 ) }, `max-width: 3;` },
138
143
{func (s S ) S { return s .PaddingBottom (3 ) }, `padding-bottom: 3;` },
@@ -149,13 +154,40 @@ func TestStyle(t *testing.T) {
149
154
{func (s S ) S { return s .Padding (1 , 2 , 3 , 4 ) }, `padding-bottom: 3; padding-left: 4; padding-right: 2; padding-top: 1;` },
150
155
{func (s S ) S { return s .Padding (1 , 2 , 3 ) }, `padding-bottom: 3; padding-left: 2; padding-right: 2; padding-top: 1;` },
151
156
{func (s S ) S { return s .Padding (1 , 2 ) }, `padding-bottom: 1; padding-left: 2; padding-right: 2; padding-top: 1;` },
157
+ {func (s S ) S { return s .Padding (1 ) }, `padding-bottom: 1; padding-left: 1; padding-right: 1; padding-top: 1;` },
152
158
{func (s S ) S { return s .Padding () }, `` },
153
159
{func (s S ) S { return s .Padding (1 , 2 , 3 , 4 , 5 ) }, `` },
154
160
{func (s S ) S { return s .Margin (1 , 2 , 3 , 4 ) }, `margin-bottom: 3; margin-left: 4; margin-right: 2; margin-top: 1;` },
155
161
{func (s S ) S { return s .Margin (1 , 2 , 3 ) }, `margin-bottom: 3; margin-left: 2; margin-right: 2; margin-top: 1;` },
156
162
{func (s S ) S { return s .Margin (1 , 2 ) }, `margin-bottom: 1; margin-left: 2; margin-right: 2; margin-top: 1;` },
163
+ {func (s S ) S { return s .Margin (1 ) }, `margin-bottom: 1; margin-left: 1; margin-right: 1; margin-top: 1;` },
157
164
{func (s S ) S { return s .Margin () }, `` },
158
165
{func (s S ) S { return s .Margin (1 , 2 , 3 , 4 , 5 ) }, `` },
166
+ {func (s S ) S {
167
+ return s .Border (lipgloss.Border {}, true , true , true , true )
168
+ }, `border-bottom: true; border-left: true; border-right: true; ` +
169
+ `border-top: true;` },
170
+ {func (s S ) S {
171
+ return s .Border (lipgloss.Border {}, true , true , true )
172
+ }, `border-bottom: true; border-left: true; border-right: true; ` +
173
+ `border-top: true;` },
174
+ {func (s S ) S {
175
+ return s .Border (lipgloss.Border {}, true , true )
176
+ }, `border-bottom: true; border-left: true; border-right: true; ` +
177
+ `border-top: true;` },
178
+ {func (s S ) S {
179
+ return s .Border (lipgloss.Border {})
180
+ }, `border-bottom: true; border-left: true; border-right: true; ` +
181
+ `border-top: true;` },
182
+ {func (s S ) S {
183
+ return s .Border (lipgloss.Border {}, true , true , true , true , true )
184
+ }, `border-bottom: true; border-left: true; border-right: true; ` +
185
+ `border-top: true;` },
186
+ {func (s S ) S { return s .BorderBackground (g , r , b , w ) }, `border-bottom-background: #00f; border-left-background: #fff; border-right-background: #f00; border-top-background: #0f0;` },
187
+ {func (s S ) S { return s .BorderBackground (g , r , b ) }, `border-bottom-background: #00f; border-left-background: #f00; border-right-background: #f00; border-top-background: #0f0;` },
188
+ {func (s S ) S { return s .BorderBackground (g , r ) }, `border-bottom-background: #0f0; border-left-background: #f00; border-right-background: #f00; border-top-background: #0f0;` },
189
+ {func (s S ) S { return s .BorderBackground () }, `` },
190
+ {func (s S ) S { return s .BorderBackground (g , r , b , w , g ) }, `` },
159
191
}
160
192
161
193
for _ , tc := range td {
0 commit comments