package utils

import "testing"

func TestNormalizeStatus(t *testing.T) {
	tests := []struct {
		name       string
		entityType string
		input      string
		want       string
	}{
		{name: "sr completed", entityType: "sr", input: "completed", want: "submitted"},
		{name: "sr verified", entityType: "sr", input: " verified ", want: "approved"},
		{name: "sr already canonical", entityType: "sr", input: "approved", want: "approved"},
		{name: "unknown entity", entityType: "unknown", input: "MixedCase", want: "mixedcase"},
	}

	for _, tc := range tests {
		t.Run(tc.name, func(t *testing.T) {
			if got := NormalizeStatus(tc.entityType, tc.input); got != tc.want {
				t.Fatalf("NormalizeStatus(%q, %q) = %q, want %q", tc.entityType, tc.input, got, tc.want)
			}
		})
	}
}

func TestNormalizeTab(t *testing.T) {
	tests := []struct {
		name       string
		entityType string
		input      string
		defaultVal string
		want       string
	}{
		{name: "sr verified alias", entityType: "sr", input: "verified", defaultVal: "all", want: "completed"},
		{name: "sr fallback to default", entityType: "sr", input: "", defaultVal: "all", want: "all"},
		{name: "unknown entity passthrough", entityType: "unknown", input: "Draft", defaultVal: "all", want: "draft"},
	}

	for _, tc := range tests {
		t.Run(tc.name, func(t *testing.T) {
			if got := NormalizeTab(tc.entityType, tc.input, tc.defaultVal); got != tc.want {
				t.Fatalf("NormalizeTab(%q, %q, %q) = %q, want %q", tc.entityType, tc.input, tc.defaultVal, got, tc.want)
			}
		})
	}
}
