mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add CSS class tests for check boxes and radio buttons
This commit is contained in:
@@ -22,6 +22,11 @@ async def test_checkbox_initial_state() -> None:
|
|||||||
"""The initial states of the check boxes should be as we specified."""
|
"""The initial states of the check boxes should be as we specified."""
|
||||||
async with CheckboxApp().run_test() as pilot:
|
async with CheckboxApp().run_test() as pilot:
|
||||||
assert [box.value for box in pilot.app.query(Checkbox)] == [False, False, True]
|
assert [box.value for box in pilot.app.query(Checkbox)] == [False, False, True]
|
||||||
|
assert [box.has_class("-on") for box in pilot.app.query(Checkbox)] == [
|
||||||
|
False,
|
||||||
|
False,
|
||||||
|
True,
|
||||||
|
]
|
||||||
assert pilot.app.events_received == []
|
assert pilot.app.events_received == []
|
||||||
|
|
||||||
|
|
||||||
@@ -31,6 +36,11 @@ async def test_checkbox_toggle() -> None:
|
|||||||
for box in pilot.app.query(Checkbox):
|
for box in pilot.app.query(Checkbox):
|
||||||
box.toggle()
|
box.toggle()
|
||||||
assert [box.value for box in pilot.app.query(Checkbox)] == [True, True, False]
|
assert [box.value for box in pilot.app.query(Checkbox)] == [True, True, False]
|
||||||
|
assert [box.has_class("-on") for box in pilot.app.query(Checkbox)] == [
|
||||||
|
True,
|
||||||
|
True,
|
||||||
|
False,
|
||||||
|
]
|
||||||
await pilot.pause()
|
await pilot.pause()
|
||||||
assert pilot.app.events_received == [
|
assert pilot.app.events_received == [
|
||||||
("cb1", True),
|
("cb1", True),
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ async def test_radio_button_initial_state() -> None:
|
|||||||
False,
|
False,
|
||||||
True,
|
True,
|
||||||
]
|
]
|
||||||
|
assert [button.has_class("-on") for button in pilot.app.query(RadioButton)] == [
|
||||||
|
False,
|
||||||
|
False,
|
||||||
|
True,
|
||||||
|
]
|
||||||
assert pilot.app.events_received == []
|
assert pilot.app.events_received == []
|
||||||
|
|
||||||
|
|
||||||
@@ -39,6 +44,11 @@ async def test_radio_button_toggle() -> None:
|
|||||||
True,
|
True,
|
||||||
False,
|
False,
|
||||||
]
|
]
|
||||||
|
assert [button.has_class("-on") for button in pilot.app.query(RadioButton)] == [
|
||||||
|
True,
|
||||||
|
True,
|
||||||
|
False,
|
||||||
|
]
|
||||||
await pilot.pause()
|
await pilot.pause()
|
||||||
assert pilot.app.events_received == [
|
assert pilot.app.events_received == [
|
||||||
("rb1", True),
|
("rb1", True),
|
||||||
|
|||||||
Reference in New Issue
Block a user