Backend: Add tests to pkg/colors

This commit is contained in:
Theresa Gresch 2020-04-28 16:00:42 +02:00
parent 0cfb1421ba
commit f51280b541
3 changed files with 33 additions and 2 deletions

View file

@ -0,0 +1,32 @@
package colors
import (
"github.com/lucasb-eyer/go-colorful"
"github.com/stretchr/testify/assert"
"image/color"
"testing"
)
func TestColorful(t *testing.T) {
t.Run("purple", func(t *testing.T) {
c := color.RGBA{0x6a, 0x1b, 0x9a, 0xff}
color, ok := colorful.MakeColor(c)
if !ok {
t.Fatal("ok should be true")
}
assert.Equal(t, "purple", Colorful(color).Name())
})
t.Run("cyan", func(t *testing.T) {
c := color.RGBA{0xb2, 0xeb, 0xf2, 0xff}
color, ok := colorful.MakeColor(c)
if !ok {
t.Fatal("ok should be true")
}
assert.Equal(t, "cyan", Colorful(color).Name())
})
}

View file

@ -16,7 +16,7 @@ func TestColors_List(t *testing.T) {
func TestColor_Hex(t *testing.T) {
assert.Equal(t, "C", Magenta.Hex())
assert.Equal(t, 7, Cyan.Hex())
assert.Equal(t, "7", Cyan.Hex())
}
func TestColors_Hex(t *testing.T) {

View file

@ -8,5 +8,4 @@ import (
func TestLuminance_Hex(t *testing.T) {
lum := Luminance(1)
assert.Equal(t, "1", lum.Hex())
}