Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
frnhr committed Mar 27, 2024
1 parent c57f06e commit d0d9a91
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/test_enrich.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,42 @@ def update(n_clicks2, n_clicks4):
assert log.text == "1-1"


def test_trigger_transform_clientside(dash_duo):
app = DashProxy(prevent_initial_callbacks=True, transforms=[TriggerTransform()])
app.layout = html.Div([
html.Button(id="btn1"),
html.Button(id="btn2"),
html.Button(id="btn3"),
html.Button(id="btn4"),
html.Div(id="log"),
])

app.clientside_callback(
"""(nClicks2, nClicks4) => `${nClicks2}-${nClicks4}`""",
Output("log", "children"),
Trigger("btn1", "n_clicks"),
Input("btn2", "n_clicks"),
Trigger("btn3", "n_clicks"),
State("btn4", "n_clicks"))

# Check that the app works.
dash_duo.start_server(app)
log = dash_duo.find_element("#log")
assert log.text == ""
dash_duo.find_element("#btn1").click()
time.sleep(0.1)
assert log.text == "undefined-undefined"
dash_duo.find_element("#btn2").click()
time.sleep(0.1)
assert log.text == "1-undefined"
dash_duo.find_element("#btn4").click()
time.sleep(0.1)
assert log.text == "1-undefined"
dash_duo.find_element("#btn3").click()
time.sleep(0.1)
assert log.text == "1-1"


@pytest.mark.parametrize(
'args, kwargs',
[([Output("log", "children"), Input("right", "n_clicks")], dict()),
Expand Down

0 comments on commit d0d9a91

Please sign in to comment.