package domain_test

import (
	"testing"

	"source.toby3d.me/toby3d/home/internal/domain"
)

func TestMediaType_Type(t *testing.T) {
	t.Parallel()

	for name, tc := range map[string]struct {
		input  string
		expect string
	}{
		"exists": {input: "image/jpeg", expect: "image/jpeg"},
		"main":   {input: "image/", expect: ""},
		"sub":    {input: "/jpeg", expect: ""},
		"params": {input: "image/svg+xml", expect: "image/svg+xml"},
	} {
		tc, name := tc, name

		t.Run(name, func(t *testing.T) {
			t.Parallel()

			actual := domain.NewMediaType(tc.input).Type()
			if actual != tc.expect {
				t.Errorf("got '%s', want '%s'", actual, tc.expect)
			}
		})
	}
}
