[Fix: issue 582] Icon tag should work despite case sensitivity. (#588)
This commit is contained in:
parent
1204aa8a26
commit
37edaa2f6b
@ -38,7 +38,7 @@ class Icon(ChakraIconComponent):
|
|||||||
)
|
)
|
||||||
if "tag" not in props.keys():
|
if "tag" not in props.keys():
|
||||||
raise AttributeError("Missing 'tag' keyword-argument for Icon")
|
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(
|
raise ValueError(
|
||||||
f"Invalid icon tag: {props['tag']}. Please use one of the following: {ICON_LIST}"
|
f"Invalid icon tag: {props['tag']}. Please use one of the following: {ICON_LIST}"
|
||||||
)
|
)
|
||||||
|
@ -39,3 +39,17 @@ def test_invalid_icon(tag):
|
|||||||
"""
|
"""
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
Icon.create(tag=tag)
|
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"
|
||||||
|
Loading…
Reference in New Issue
Block a user