disagreement/tests/test_components_factory.py
2025-06-09 22:25:14 -06:00

30 lines
802 B
Python

from disagreement.components import component_factory
from disagreement.enums import ComponentType, ButtonStyle
def test_component_factory_button():
data = {
"type": ComponentType.BUTTON.value,
"style": ButtonStyle.PRIMARY.value,
"label": "Click",
"custom_id": "x",
}
comp = component_factory(data)
assert comp.to_dict()["label"] == "Click"
def test_component_factory_action_row():
data = {
"type": ComponentType.ACTION_ROW.value,
"components": [
{
"type": ComponentType.BUTTON.value,
"style": ButtonStyle.PRIMARY.value,
"label": "A",
"custom_id": "b",
}
],
}
row = component_factory(data)
assert len(row.components) == 1