package webui

import "testing"

func TestIsValidDomainName(t *testing.T) {
	valid := []string{"example.com", "mail.example.com", "my-domain.org", "company.co.uk"}
	invalid := []string{"zczsdc", "example", "", ".example.com", "http://example.com", "example..com"}

	for _, d := range valid {
		if !isValidDomainName(d) {
			t.Errorf("isValidDomainName(%q) = false, want true", d)
		}
	}
	for _, d := range invalid {
		if isValidDomainName(d) {
			t.Errorf("isValidDomainName(%q) = true, want false", d)
		}
	}
}

func TestVerificationRecordNameAndValue(t *testing.T) {
	if got := verificationRecordName("example.com"); got != "_pymta-verify.example.com" {
		t.Errorf("verificationRecordName = %q", got)
	}
	if got := verificationRecordValue("abc123"); got != "pymta-verify=abc123" {
		t.Errorf("verificationRecordValue = %q", got)
	}
}
