From 37edaa2f6bbfad9d658d952ba723d08bee9a924c Mon Sep 17 00:00:00 2001 From: Xiaojing Chen Date: Wed, 22 Feb 2023 09:32:34 +0800 Subject: [PATCH] [Fix: issue 582] Icon tag should work despite case sensitivity. (#588) --- pynecone/components/media/icon.py | 2 +- tests/components/media/test_icon.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pynecone/components/media/icon.py b/pynecone/components/media/icon.py index 0d9ccf4b8..6408e42b8 100644 --- a/pynecone/components/media/icon.py +++ b/pynecone/components/media/icon.py @@ -38,7 +38,7 @@ class Icon(ChakraIconComponent): ) if "tag" not in props.keys(): raise AttributeError("Missing 'tag' keyword-argument for Icon") - if props["tag"] not in ICON_LIST: + if type(props["tag"]) != str or props["tag"].lower() not in ICON_LIST: raise ValueError( f"Invalid icon tag: {props['tag']}. Please use one of the following: {ICON_LIST}" ) diff --git a/tests/components/media/test_icon.py b/tests/components/media/test_icon.py index dc1480b0d..bf82d8449 100644 --- a/tests/components/media/test_icon.py +++ b/tests/components/media/test_icon.py @@ -39,3 +39,17 @@ def test_invalid_icon(tag): """ with pytest.raises(ValueError): Icon.create(tag=tag) + + +@pytest.mark.parametrize( + "tag", + ["Check", "Close", "eDit"], +) +def test_tag_with_capital(tag: str): + """Test that an icon that tag with capital does not raise an error. + + Args: + tag: The icon tag. + """ + icon = Icon.create(tag=tag) + assert icon.tag == utils.to_title_case(tag) + "Icon"