v4/presentation/role_test.go
2025-04-05 22:02:17 -07:00

33 lines
1 KiB
Go

package presentation_test
import (
"testing"
"git.sapphic.engineer/roleypoly/v4/presentation"
"git.sapphic.engineer/roleypoly/v4/types/fixtures"
"github.com/stretchr/testify/assert"
)
func TestRole(t *testing.T) {
r := presentation.Role(&fixtures.CategoryMulti, &fixtures.RoleWithDarkColor, true)
assert.Equal(t, fixtures.RoleWithDarkColor.ID, r.ID)
assert.Equal(t, fixtures.RoleWithDarkColor.Name, r.Name)
assert.Equal(t, presentation.InputCheckbox, r.InputType)
assert.Equal(t, "#a20000", r.Colors.Main)
assert.True(t, r.Colors.IsDark)
assert.True(t, r.Selected)
r = presentation.Role(&fixtures.CategorySingle, &fixtures.RoleWithDarkColor, false)
assert.Equal(t, presentation.InputRadio, r.InputType)
assert.False(t, r.Selected)
r = presentation.Role(&fixtures.CategorySingle, &fixtures.RoleWithLightColor, true)
assert.False(t, r.Colors.IsDark)
assert.True(t, r.Selected)
}
func TestGetColors(t *testing.T) {
c := presentation.GetColors(0xa20000)
assert.Equal(t, "#a20000", c.Main)
assert.True(t, c.IsDark)
}