from fmatch.saas.operators.company_size_bucket import company_size_bucket


def test_company_size_bucket_infers_missing_range_suffix():
    result = company_size_bucket("10-50K")
    assert result["value"] == "Strategic/Global"
    assert result["numeric"] == 30000
    assert result["meta"]["range_low"] == 10000
    assert result["meta"]["range_high"] == 50000
    assert result["meta"]["shared_suffix_inferred"] is True


def test_company_size_bucket_infers_suffix_on_trailing_bound():
    result = company_size_bucket("10K-50")
    assert result["value"] == "Strategic/Global"
    assert result["numeric"] == 30000
    assert result["meta"]["range_low"] == 10000
    assert result["meta"]["range_high"] == 50000
    assert result["meta"]["shared_suffix_inferred"] is True


def test_company_size_bucket_normalizes_unicode_dash_ranges():
    result = company_size_bucket("10\u201350K")
    assert result["value"] == "Strategic/Global"
    assert result["numeric"] == 30000


def test_company_size_bucket_rejects_mixed_suffix_ranges():
    result = company_size_bucket("10K-1M")
    assert result["value"] is None
    assert result["numeric"] is None
    assert result["meta"]["reason"] == "ambiguous_range"
