Skip to content

Commit

Permalink
move hooks out of test def
Browse files Browse the repository at this point in the history
  • Loading branch information
rmorshea committed Jan 27, 2022
1 parent 8502a5e commit d4bbcd4
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tests/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
from idom.utils import Ref


def use_toggle():
state, set_state = use_state(True)
return state, lambda: set_state(not state)


def use_counter():
state, set_state = use_state(1)
return state, lambda: set_state(state + 1)


def test_script_mount_unmount(driver, driver_wait, display):
toggle_is_mounted = Ref()

def use_toggle():
state, set_state = use_state(True)
return state, lambda: set_state(not state)

@component
def Root():
is_mounted, toggle_is_mounted.current = use_toggle()
Expand Down Expand Up @@ -53,10 +59,6 @@ def HasScript():
def test_script_re_run_on_content_change(driver, driver_wait, display):
incr_count = Ref()

def use_counter():
state, set_state = use_state(1)
return state, lambda: set_state(state + 1)

@component
def HasScript():
count, incr_count.current = use_counter()
Expand Down

0 comments on commit d4bbcd4

Please sign in to comment.