reflex/tests/components/lucide/test_icon.py
Thomas Brandého bf0ebb8d09
Lendemor/improve coverage (#2988)
* add more tests

* add tests to raise coverage

* more tests, bump coverage to 73

* fix up icon_button test

* fix darglint for app.py

* fix utcnow usage warning

* set threshold to 72

* fix timestamp

* fix unit tests for linux-redis

* removed commented code and put a TODO
2024-04-04 14:31:43 +02:00

42 lines
1.1 KiB
Python

import pytest
from reflex.components.lucide.icon import LUCIDE_ICON_LIST, RENAMED_ICONS_05, Icon
from reflex.components.radix.themes.base import Theme
from reflex.utils import format
@pytest.mark.parametrize("tag", LUCIDE_ICON_LIST)
def test_icon(tag):
icon = Icon.create(tag)
assert icon.alias == f"Lucide{format.to_title_case(tag)}Icon"
RENAMED_TAGS = [tag for tag in RENAMED_ICONS_05.items()]
@pytest.mark.parametrize("tag, new_tag", RENAMED_TAGS)
def test_icon_renamed_tags(tag, new_tag):
Icon.create(tag)
# need a PR so we can pass the following test. Currently it fails and uses the old tag as the import.
# assert icon.alias == f"Lucide{format.to_title_case(new_tag)}Icon"
def test_icon_missing_tag():
with pytest.raises(AttributeError):
_ = Icon.create()
def test_icon_invalid_tag():
with pytest.raises(ValueError):
_ = Icon.create("invalid-tag")
def test_icon_multiple_children():
with pytest.raises(AttributeError):
_ = Icon.create("activity", "child1", "child2")
def test_icon_apply_theme():
ic = Icon.create("activity")
ic._apply_theme(Theme())