HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/Lib/site-packages/panel/tests/widgets/test_icon.py
import pytest

from panel.widgets.icon import ToggleIcon


class TestToggleIcon:

    def test_init(self):
        icon = ToggleIcon()
        assert icon.icon == "heart"
        assert icon.active_icon == ""
        assert not icon.value

    def test_custom_values(self):
        icon = ToggleIcon(icon="thumb-down", active_icon="thumb-up", value=True)
        assert icon.icon == "thumb-down"
        assert icon.active_icon == "thumb-up"
        assert icon.value

    def test_empty_icon(self):
        with pytest.raises(ValueError, match="The icon parameter must not "):
            ToggleIcon(icon="")

    def test_icon_svg_empty_active_icon(self):
        with pytest.raises(ValueError, match="The active_icon parameter must not "):
            ToggleIcon(icon="<svg></svg>")