from app.services.scrapers.avito import _clean_address


def test_strips_css_noise():
    raw = (
        "ул. Токарей, 56к1Площадь 1905 года.css-39hgr0{fill:currentColor;"
        "height:1em;box-sizing:border-box;}.css-39hgr0:focus{outline:none;}"
        "от 31 мин.Геологическая.css-39hgr0{...}"
    )
    assert _clean_address(raw) == "ул. Токарей, 56к1"


def test_clean_address_passthrough():
    assert _clean_address("ул. Малышева, 1") == "ул. Малышева, 1"


def test_clean_handles_none():
    assert _clean_address(None) is None
    assert _clean_address("") is None
    assert _clean_address("   ") is None


def test_clean_strips_trailing_punctuation():
    assert _clean_address("ул. Ленина, 5,") == "ул. Ленина, 5"
