package payments

import "testing"

func TestCanTransition(t *testing.T) {
	tests := []struct {
		name string
		from string
		to   string
		want bool
	}{
		{name: "pending to processing", from: StatusPending, to: StatusProcessing, want: true},
		{name: "pending to review held", from: StatusPending, to: StatusReviewHeld, want: true},
		{name: "review held to pending", from: StatusReviewHeld, to: StatusPending, want: true},
		{name: "review held to rejected", from: StatusReviewHeld, to: StatusRejected, want: true},
		{name: "processing to failed", from: StatusProcessing, to: StatusFailed, want: true},
		{name: "completed cannot go pending", from: StatusCompleted, to: StatusPending, want: false},
		{name: "pending cannot complete directly", from: StatusPending, to: StatusCompleted, want: false},
	}

	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			if got := CanTransition(test.from, test.to); got != test.want {
				t.Fatalf("CanTransition(%q, %q) = %v, want %v", test.from, test.to, got, test.want)
			}
		})
	}
}

func TestFallbackReason(t *testing.T) {
	reason := fallbackReason(ProviderLocalSEPA, "provider code")
	if reason.InternalCode != "provider_code" {
		t.Fatalf("InternalCode = %q, want provider_code", reason.InternalCode)
	}
	if reason.Category != "system" {
		t.Fatalf("Category = %q, want system", reason.Category)
	}
}
