46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
from dataclasses import dataclass
|
|
|
|
import pytest
|
|
from fasthtml.fastapp import fast_app
|
|
|
|
from myfasthtml.test.testclient import MyTestClient, TestableTextarea
|
|
|
|
|
|
@dataclass
|
|
class Data:
|
|
value: str = "hello world"
|
|
|
|
|
|
@pytest.fixture
|
|
def test_app():
|
|
test_app, rt = fast_app(default_hdrs=False)
|
|
return test_app
|
|
|
|
|
|
@pytest.fixture
|
|
def rt(test_app):
|
|
return test_app.route
|
|
|
|
|
|
@pytest.fixture
|
|
def test_client(test_app):
|
|
return MyTestClient(test_app)
|
|
|
|
|
|
def test_i_can_read_input(test_client):
|
|
html = '''<textarea name="textarea_name">Lorem ipsum</textarea>'''
|
|
|
|
input_elt = TestableTextarea(test_client, html)
|
|
|
|
assert input_elt.name == "textarea_name"
|
|
assert input_elt.value == "Lorem ipsum"
|
|
|
|
|
|
@pytest.mark.skip("To update later")
|
|
def test_i_can_read_input_with_label(test_client):
|
|
html = '''<label for="uid">Text Area</label><textarea id="uid" name="textarea_name">Lorem ipsum</textarea>'''
|
|
|
|
input_elt = TestableTextarea(test_client, html)
|
|
assert input_elt.fields_mapping == {"Text Area": "textarea_name"}
|
|
assert input_elt.name == "textarea_name"
|
|
assert input_elt.value == "Lorem ipsum" |