Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more Input tests, remove duplicate value callbacks. #384

Merged
merged 16 commits into from Dec 4, 2018

Add simple-callback input test.

  • Loading branch information...
T4rk1n committed Dec 3, 2018
commit 59becf6cc86b178d808be878dd80b22a20baf23a
@@ -1558,3 +1558,51 @@ def update_output(input, state):
self.assertEqual(
output().text,
'input="Initial Inputxy", state="Initial Statex"')

def test_simple_callback(self):
app = dash.Dash(__name__)
app.layout = html.Div([
dcc.Input(
id='input',
value='initial value'
),
html.Div(
html.Div([
1.5,
None,
'string',
html.Div(id='output-1')
])
)
])

call_count = Value('i', 0)

@app.callback(Output('output-1', 'children'), [Input('input', 'value')])
def update_output(value):
call_count.value = call_count.value + 1
return value

self.startServer(app)

output1 = self.wait_for_element_by_css_selector('#output-1')
wait_for(lambda: output1.text == 'initial value')
self.snapshot(name='simple-callback-1')

input1 = self.wait_for_element_by_css_selector('#input')
input1.clear()

input1.send_keys('hello world')

self.wait_for_text_to_equal('#output-1', 'hello world')
output1.click() # Lose focus
self.snapshot(name='simple-callback-2')

self.assertEqual(
call_count.value,
# an initial call to retrieve the first value
1 +
# one for each hello world character
len('hello world')
)

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.