package discovery

import "testing"

func TestProfileHasValueBeyondEmail(t *testing.T) {
	tests := []struct {
		name string
		p    Profile
		want bool
	}{
		{
			name: "email only",
			p: Profile{
				PrimaryEmail: "alice@corp.com",
				DisplayName:  "",
			},
			want: false,
		},
		{
			name: "display name equals local part",
			p: Profile{
				PrimaryEmail: "alice@corp.com",
				DisplayName:  "alice",
			},
			want: false,
		},
		{
			name: "meaningful display name",
			p: Profile{
				PrimaryEmail: "alice@corp.com",
				DisplayName:  "Alice Martin",
			},
			want: true,
		},
		{
			name: "signature",
			p: Profile{
				PrimaryEmail: "alice@corp.com",
				Signatures: []SignatureEntry{{
					SignatureText: "Alice Martin\nCorp",
				}},
			},
			want: true,
		},
		{
			name: "enriched company",
			p: Profile{
				PrimaryEmail: "alice@corp.com",
				EnrichedData: &EnrichedContactData{Company: "Corp"},
			},
			want: true,
		},
		{
			name: "all emails display name",
			p: Profile{
				PrimaryEmail: "alice@corp.com",
				AllEmails: []EmailEntry{{
					Email:       "alice@corp.com",
					DisplayName: "Alice Martin",
				}},
			},
			want: true,
		},
	}

	for _, tc := range tests {
		t.Run(tc.name, func(t *testing.T) {
			if got := ProfileHasValueBeyondEmail(tc.p); got != tc.want {
				t.Fatalf("ProfileHasValueBeyondEmail() = %v, want %v", got, tc.want)
			}
		})
	}
}
