diff --git a/pkg/colors/colorful_test.go b/pkg/colors/colorful_test.go new file mode 100644 index 000000000..40f504b9a --- /dev/null +++ b/pkg/colors/colorful_test.go @@ -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()) + }) +} diff --git a/pkg/colors/colors_test.go b/pkg/colors/colors_test.go index d61e6ff05..903614a7a 100644 --- a/pkg/colors/colors_test.go +++ b/pkg/colors/colors_test.go @@ -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) { diff --git a/pkg/colors/luminance_test.go b/pkg/colors/luminance_test.go index b7409ad65..c800d8448 100644 --- a/pkg/colors/luminance_test.go +++ b/pkg/colors/luminance_test.go @@ -8,5 +8,4 @@ import ( func TestLuminance_Hex(t *testing.T) { lum := Luminance(1) assert.Equal(t, "1", lum.Hex()) - }