package domain

import (
	"testing"
)

func TestValidateLoginID(t *testing.T) {
	tests := []struct {
		name    string
		loginID string
		email   string
		phone   string
		wantErr bool
	}{
		{"Empty", "", "test@email.com", "01012345678", false},
		{"Valid alphanumeric", "user123", "test@email.com", "01012345678", false},
		{"Too short", "us", "test@email.com", "01012345678", true},
		{"Too long", "thisisaverylongloginidthatiswayoverthirtycharacters", "test@email.com", "01012345678", true},
		{"Email format", "user@domain.com", "test@email.com", "01012345678", true},
		{"Exact email match", "Test@Email.Com", "test@email.com", "01012345678", true},
		{"Phone number match", "010-1234-5678", "test@email.com", "01012345678", true},
		{"Phone number match +82", "+821012345678", "test@email.com", "01012345678", true},
		{"Phone number match digits", "01012345678", "test@email.com", "01012345678", true},
		{"Phone format (11 digits)", "01098765432", "test@email.com", "01012345678", true},
		{"Valid pure digits (employee ID)", "20230001", "test@email.com", "01012345678", false},
		{"Valid pure digits long", "123456789", "test@email.com", "01012345678", false},
		{"Valid pure digits 10 chars", "1234567890", "test@email.com", "01012345678", false},
		{"Reserved word admin", "ADMIN", "test@email.com", "01012345678", true},
		{"Reserved word root", "root", "test@email.com", "01012345678", true},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			err := ValidateLoginID(tt.loginID, tt.email, tt.phone)
			if (err != nil) != tt.wantErr {
				t.Errorf("ValidateLoginID() error = %v, wantErr %v", err, tt.wantErr)
			}
		})
	}
}
