mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Merge branch 'main' into remove-refresh
This commit is contained in:
26
tests/test_reactive.py
Normal file
26
tests/test_reactive.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.reactive import reactive
|
||||
|
||||
|
||||
class WatchApp(App):
|
||||
|
||||
count = reactive(0, init=False)
|
||||
|
||||
test_count = 0
|
||||
|
||||
def watch_count(self, value: int) -> None:
|
||||
self.test_count = value
|
||||
|
||||
|
||||
async def test_watch():
|
||||
"""Test that changes to a watched reactive attribute happen immediately."""
|
||||
app = WatchApp()
|
||||
async with app.run_test():
|
||||
app.count += 1
|
||||
assert app.test_count == 1
|
||||
app.count += 1
|
||||
assert app.test_count == 2
|
||||
app.count -= 1
|
||||
assert app.test_count == 1
|
||||
app.count -= 1
|
||||
assert app.test_count == 0
|
||||
Reference in New Issue
Block a user