Added TestableCheckbox
This commit is contained in:
0
tests/controls/__init__.py
Normal file
0
tests/controls/__init__.py
Normal file
48
tests/controls/test_helpers.py
Normal file
48
tests/controls/test_helpers.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import pytest
|
||||
from fasthtml.components import *
|
||||
from fasthtml.fastapp import fast_app
|
||||
|
||||
from myfasthtml.controls.helpers import mk
|
||||
from myfasthtml.core.commands import Command
|
||||
from myfasthtml.test.matcher import matches
|
||||
from myfasthtml.test.testclient import MyTestClient
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def user():
|
||||
test_app, rt = fast_app(default_hdrs=False)
|
||||
user = MyTestClient(test_app)
|
||||
return user
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def rt(user):
|
||||
return user.app.route
|
||||
|
||||
|
||||
def test_i_can_mk_button():
|
||||
button = mk.button('button')
|
||||
expected = Button('button')
|
||||
|
||||
assert matches(button, expected)
|
||||
|
||||
|
||||
def test_i_can_mk_button_with_attrs():
|
||||
button = mk.button('button', id="button_id", class_="button_class")
|
||||
expected = Button('button', id="button_id", class_="button_class")
|
||||
assert matches(button, expected)
|
||||
|
||||
|
||||
def test_i_can_mk_button_with_command(user, rt):
|
||||
def new_value(value): return value
|
||||
|
||||
command = Command('test', 'TestingCommand', new_value, "this is my new value")
|
||||
|
||||
@rt('/')
|
||||
def get(): return mk.button('button', command)
|
||||
|
||||
user.open("/")
|
||||
user.should_see("button")
|
||||
|
||||
user.find_element("button").click()
|
||||
user.should_see("this is my new value")
|
||||
Reference in New Issue
Block a user