package userbehavior

import "testing"

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

	tests := []struct {
		name      string
		selectors []string
		bizRegion string
		country   string
		want      bool
		wantType  string
	}{
		{"disabled_empty", nil, "NA", "US", false, ""},
		{"disabled_empty_after_trim", []string{"", "  "}, "NA", "US", false, ""},
		{"region_match_case_insensitive", []string{"na"}, "NA", "US", true, "region"},
		{"region_match_japan_alias", []string{"jp"}, "JAPAN", "JP", true, "region"},
		{"region_match_japan_literal", []string{"japan"}, "JAPAN", "JP", true, "region"},
		{"country_match_uppercase_config", []string{"US"}, "EMEA", "US", true, "country"},
		{"country_match_lowercase", []string{"us"}, "EMEA", "US", true, "country"},
		{"no_match", []string{"emea"}, "NA", "US", false, ""},
	}

	for _, tt := range tests {
		tt := tt
		t.Run(tt.name, func(t *testing.T) {
			got, gotType := matchGeoSelectors(tt.selectors, tt.bizRegion, tt.country)
			if got != tt.want || gotType != tt.wantType {
				t.Fatalf("got (%v,%q), want (%v,%q)", got, gotType, tt.want, tt.wantType)
			}
		})
	}
}
