37 lines
699 B
Python
37 lines
699 B
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"
|