feat(ui): Add support for buttons below header (#106)
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@ -26,6 +27,45 @@ func TestConfig_ValidateAndSetDefaults(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestButton_Validate(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
Name, Link string
|
||||
ExpectedError error
|
||||
}{
|
||||
{
|
||||
Name: "",
|
||||
Link: "",
|
||||
ExpectedError: ErrButtonValidationFailed,
|
||||
},
|
||||
{
|
||||
Name: "",
|
||||
Link: "link",
|
||||
ExpectedError: ErrButtonValidationFailed,
|
||||
},
|
||||
{
|
||||
Name: "name",
|
||||
Link: "",
|
||||
ExpectedError: ErrButtonValidationFailed,
|
||||
},
|
||||
{
|
||||
Name: "name",
|
||||
Link: "link",
|
||||
ExpectedError: nil,
|
||||
},
|
||||
}
|
||||
for i, scenario := range scenarios {
|
||||
t.Run(strconv.Itoa(i)+"_"+scenario.Name+"_"+scenario.Link, func(t *testing.T) {
|
||||
button := &Button{
|
||||
Name: scenario.Name,
|
||||
Link: scenario.Link,
|
||||
}
|
||||
if err := button.Validate(); err != scenario.ExpectedError {
|
||||
t.Errorf("expected error %v, got %v", scenario.ExpectedError, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetDefaultConfig(t *testing.T) {
|
||||
defaultConfig := GetDefaultConfig()
|
||||
if defaultConfig.Title != defaultTitle {
|
||||
|
Reference in New Issue
Block a user