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

This commit is contained in:
Xiaojing Chen 2023-02-22 09:32:34 +08:00 committed by GitHub
parent 1204aa8a26
commit 37edaa2f6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -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}"
)

View File

@ -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"