import pytest
from lilies.style.palette import hex_color, rgb, InvalidHexCodeError


@pytest.mark.parametrize(
    "hex_code,expected_color",
    [
        ("#fff", rgb(255, 255, 255)),
        ("fff", rgb(255, 255, 255)),
        ("#123456", rgb(18, 52, 86)),
        ("123456", rgb(18, 52, 86)),
    ],
)
def test_hex_color_conversion(hex_code, expected_color):
    actual_color = hex_color(hex_code)
    assert expected_color == actual_color


@pytest.mark.parametrize("hex_code", [("##ffffff",), ("fffff",), ("",)])
def test_hex_color_fails_on_invalid_input(hex_code):
    with pytest.raises(InvalidHexCodeError):
        _ = hex_color(hex_code)
