Skip to content

Commit 4a67dff

Browse files
Update test to verify event handlers fail when used in rx.cond()
Co-Authored-By: khaleel@reflex.dev <khaleel.aladhami@gmail.com>
1 parent 6ac8bf4 commit 4a67dff

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/units/test_event.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,9 @@ def get_handler(self, arg: Var[str]):
485485
_ = rx.input(on_change=w.get_handler)
486486

487487

488-
def test_event_var_bool_conversion():
489-
"""Test that EventVar and EventChainVar cannot be converted to booleans."""
488+
def test_event_var_in_rx_cond():
489+
"""Test that EventVar and EventChainVar cannot be used in rx.cond()."""
490+
from reflex.components.core.cond import cond as rx_cond
490491

491492
class S(BaseState):
492493
@event
@@ -495,7 +496,7 @@ def s(self):
495496

496497
handler_var = Var.create(S.s)
497498
with pytest.raises(TypeError) as err:
498-
handler_var.bool()
499+
rx_cond(handler_var, rx.text("True"), rx.text("False"))
499500
assert "Cannot convert" in str(err.value)
500501
assert "to bool" in str(err.value)
501502

@@ -509,6 +510,6 @@ def _args_spec() -> tuple:
509510
)
510511
)
511512
with pytest.raises(TypeError) as err:
512-
chain_var.bool()
513+
rx_cond(chain_var, rx.text("True"), rx.text("False"))
513514
assert "Cannot convert" in str(err.value)
514515
assert "to bool" in str(err.value)

0 commit comments

Comments
 (0)