浏览代码

[Fix: issue 582] Icon tag should work despite case sensitivity. (#588)

Xiaojing Chen 2 年之前
父节点
当前提交
37edaa2f6b
共有 2 个文件被更改,包括 15 次插入1 次删除
  1. 1 1
      pynecone/components/media/icon.py
  2. 14 0
      tests/components/media/test_icon.py

+ 1 - 1
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}"
             )

+ 14 - 0
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"