"""Tests para clean_email."""
import sys
import os

sys.path.insert(0, os.path.dirname(__file__))

import pytest
from clean_email import clean_email


def test_angle_brackets_y_whitespace_se_limpian():
    assert clean_email(" <foo@bar.com>") == "foo@bar.com"


def test_comillas_dobles_y_mayusculas_se_normalizan():
    assert clean_email('"BAR@BAZ.com"') == "bar@baz.com"


def test_whitespace_puro_se_limpia_y_lowercase():
    assert clean_email("  Mixed.Case@Example.COM  ") == "mixed.case@example.com"


def test_email_sin_arroba_lanza_valueerror():
    with pytest.raises(ValueError):
        clean_email("not-an-email")


def test_string_vacio_lanza_valueerror():
    with pytest.raises(ValueError):
        clean_email("")


def test_email_sin_punto_en_dominio_lanza_valueerror():
    with pytest.raises(ValueError):
        clean_email("a@b")


def test_comillas_simples_se_limpian():
    assert clean_email("'user@domain.es'") == "user@domain.es"


def test_angle_brackets_con_espacio_interior():
    assert clean_email("< user@example.com >") == "user@example.com"
