package auth import "testing" func TestValidEmail(t *testing.T) { valid := []string{"a@b.com", "user.name+tag@sub.example.co", "x@y.io"} for _, e := range valid { if !ValidEmail(e) { t.Errorf("expected %q to be valid", e) } } invalid := []string{"", "no-at", "a@", "@b.com", "a@b", "a@@b.com", "a@.com", "a@b."} for _, e := range invalid { if ValidEmail(e) { t.Errorf("expected %q to be invalid", e) } } } func TestIsDisposable(t *testing.T) { if !IsDisposable("foo@mailinator.com") { t.Error("mailinator.com should be disposable") } if !IsDisposable("foo@MAILINATOR.com") { // case-insensitive t.Error("disposable check should be case-insensitive") } if IsDisposable("foo@gmail.com") { t.Error("gmail.com should not be disposable") } if IsDisposable("no-domain") { t.Error("address without domain should not be flagged disposable") } } func TestNormalizeEmail(t *testing.T) { if got := NormalizeEmail(" User@Example.COM "); got != "user@example.com" { t.Errorf("NormalizeEmail = %q", got) } }