Skip to content

Commit 37fe64d

Browse files
committed
basic test
1 parent c03edb7 commit 37fe64d

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import dash
2+
from dash.dependencies import Input, Output
3+
import dash_core_components as dcc
4+
import dash_html_components as html
5+
6+
7+
def test_dash_callback_001(dash_duo):
8+
app = dash.Dash(__name__)
9+
10+
app.layout = html.Div(
11+
[
12+
dcc.Input(id="input"),
13+
html.Div(id="div-1"),
14+
html.Div(id="div-2"),
15+
html.Div(id="div-3"),
16+
html.Div(id="div-4"),
17+
html.Div(id="div-5"),
18+
]
19+
)
20+
21+
@dash.callback(Output("div-1", "children"), Input("input", "value"))
22+
def update_1(value):
23+
return f"Input 1 - {value}"
24+
25+
@dash.callback(Output("div-2", "children"), Input("input", "value"))
26+
def update_2(value):
27+
return f"Input 2 - {value}"
28+
29+
@app.callback(Output("div-3", "children"), Input("input", "value"))
30+
def update_3(value):
31+
return f"Input 3 - {value}"
32+
33+
app.clientside_callback(
34+
"""
35+
function (args) {return ('Input 4 - ' + args);}
36+
""",
37+
Output("div-4", "children"),
38+
Input("input", "value"),
39+
)
40+
41+
dash.clientside_callback(
42+
"""
43+
function (args) {return ('Input 5 - ' + args);}
44+
""",
45+
Output("div-5", "children"),
46+
Input("input", "value"),
47+
)
48+
49+
dash_duo.start_server(app)
50+
input = dash_duo.find_element("#input")
51+
input.send_keys("dash.callback")
52+
dash_duo.wait_for_text_to_equal("#div-1", "Input 1 - dash.callback")
53+
dash_duo.wait_for_text_to_equal("#div-2", "Input 2 - dash.callback")
54+
dash_duo.wait_for_text_to_equal("#div-3", "Input 3 - dash.callback")
55+
dash_duo.wait_for_text_to_equal("#div-4", "Input 4 - dash.callback")
56+
dash_duo.wait_for_text_to_equal("#div-5", "Input 5 - dash.callback")

0 commit comments

Comments
 (0)