package reconciliation

import "testing"

func TestNormalizeRunType(t *testing.T) {
	tests := map[string]string{
		"":                  "manual",
		"manual":            "manual",
		"scheduled":         "scheduled",
		"provider_snapshot": "provider_snapshot",
		"daily":             "daily",
		"weird":             "manual",
	}
	for input, want := range tests {
		if got := normalizeRunType(input); got != want {
			t.Fatalf("normalizeRunType(%q) = %q, want %q", input, got, want)
		}
	}
}

func TestNormalizeBreakDecisionRequiresNoteForTerminalStatus(t *testing.T) {
	err := normalizeBreakDecision(&BreakDecisionParams{
		BreakID: "00000000-0000-0000-0000-000000000001",
		Status:  "resolved",
	})
	if err == nil {
		t.Fatal("expected error for missing resolution note")
	}
}

func TestNormalizeSnapshotParams(t *testing.T) {
	params := CreateSnapshotParams{
		Provider:          " local_bank_ledger ",
		ExternalAccountID: " ext-1 ",
		Currency:          "eur",
		BalanceCents:      10,
	}
	if err := normalizeSnapshotParams(&params); err != nil {
		t.Fatalf("normalizeSnapshotParams returned error: %v", err)
	}
	if params.Provider != "local_bank_ledger" || params.ExternalAccountID != "ext-1" || params.Currency != "EUR" || params.ReferenceType != "account" || params.Source != "manual" {
		t.Fatalf("unexpected normalized params: %#v", params)
	}
}
