package domain

import (
	"errors"
	"testing"
)

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

	tests := []struct {
		name     string
		currency string
		wantErr  bool
	}{
		{name: "valid", currency: "EUR"},
		{name: "lowercase after normalize", currency: NormalizeCurrency("usd")},
		{name: "too short", currency: "EU", wantErr: true},
		{name: "numeric", currency: "E1R", wantErr: true},
	}

	for _, tt := range tests {
		tt := tt
		t.Run(tt.name, func(t *testing.T) {
			t.Parallel()

			err := ValidateCurrency(tt.currency)
			if tt.wantErr && !errors.Is(err, ErrValidation) {
				t.Fatalf("expected validation error, got %v", err)
			}
			if !tt.wantErr && err != nil {
				t.Fatalf("expected no error, got %v", err)
			}
		})
	}
}

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

	if err := ValidateAmount(1); err != nil {
		t.Fatalf("expected positive amount to be valid, got %v", err)
	}
	if err := ValidateAmount(0); !errors.Is(err, ErrValidation) {
		t.Fatalf("expected validation error, got %v", err)
	}
}
