I can bind checkbox

This commit is contained in:
2025-11-07 22:27:32 +01:00
parent e8ecf72205
commit 6a05a84f0c
5 changed files with 108 additions and 39 deletions

View File

@@ -6,7 +6,7 @@ from fasthtml.components import Input, Label
from fasthtml.fastapp import fast_app
from myfasthtml.controls.helpers import mk
from myfasthtml.core.bindings import Binding, DetectionMode, UpdateMode, BooleanConverter
from myfasthtml.core.bindings import Binding
from myfasthtml.core.commands import Command, CommandsManager
from myfasthtml.test.testclient import MyTestClient, TestableElement
@@ -78,24 +78,3 @@ class TestingBindings:
testable_input = user.find_element("input")
testable_input.send("new value")
user.should_see("new value") # the one from the label
def test_i_can_bind_checkbox(self, user, rt):
@rt("/")
def index():
data = Data(True)
input_elt = Input(name="input_name", type="checkbox")
label_elt = Label()
mk.manage_binding(input_elt, Binding(data))
mk.manage_binding(label_elt, Binding(data))
return input_elt, label_elt
user.open("/")
user.should_see("")
testable_input = user.find_element("input")
testable_input.check()
user.should_see("true")
testable_input.uncheck()
user.should_see("false")