from fmatch.saas.operators.state_name_to_code import state_name_to_code


def test_state_name_to_code_maps_us_overrides():
    assert state_name_to_code("District of Columbia")["value"] == "DC"
    assert state_name_to_code("Washington, D.C.")["value"] == "DC"


def test_state_name_to_code_maps_supported_non_us_regions():
    assert state_name_to_code("Ontario")["value"] == "ON"
    assert state_name_to_code("Queensland")["value"] == "QLD"


def test_state_name_to_code_respects_explicit_country_context():
    assert state_name_to_code("Ontario", country="CA")["value"] == "ON"
    assert state_name_to_code("Ontario Province", country="CA")["value"] == "ON"
    assert state_name_to_code("Ontario", country="US")["value"] == ""
    assert state_name_to_code("California", country="CA")["value"] == ""


def test_state_name_to_code_returns_blank_for_unknown_values():
    assert state_name_to_code("Not A Real State")["value"] == ""
