Add CSS class tests for check boxes and radio buttons

This commit is contained in:
Dave Pearson
2023-02-23 21:10:21 +00:00
parent 7c6522e634
commit 236266248d
2 changed files with 20 additions and 0 deletions

View File

@@ -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),

View File

@@ -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),