from src.extractors.company_extractor import SwedishCompanyExtractor


def test_normalize_data_swedish_company_fields() -> None:
    extractor = SwedishCompanyExtractor()

    normalized = extractor._normalize_data(
        {
            "phone": "070-123 45 67",
            "org_number": "556123-4567",
            "email": "INFO@EXAMPLE.SE",
            "postal_code": "12345",
            "company_name": "Exempel AB",
            "address": "Storgatan 1",
            "city": "Stockholm",
            "website": "https://example.se",
        }
    )

    assert normalized["phone"] == "+46701234567"
    assert normalized["org_number"] == "556123-4567"
    assert normalized["email"] == "info@example.se"
    assert normalized["postal_code"] == "123 45"
    assert normalized["company_name"] == "Exempel AB"
    assert normalized["address"] == "Storgatan 1"
    assert normalized["city"] == "Stockholm"
    assert normalized["website"] == "https://example.se"


def test_html_hash_is_stable() -> None:
    extractor = SwedishCompanyExtractor()

    html = "<html><body><h1>Exempel AB</h1></body></html>"
    assert extractor._create_html_hash(html) == extractor._create_html_hash(html)
