Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
✅ fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
byron committed Jul 15, 2019
1 parent e4b0999 commit 49d979a
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions tests/integration/input/test_input_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import pytest
from selenium.common.exceptions import WebDriverException
import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html

ALLOWING_TYPES = (
"text",
"number",
"password",
"email",
"range",
"search",
"tel",
"url",
"hidden",
)


def test_intp001_all_types(dash_duo):
def input_id(type_):
return "input_{}".format(type_)

app = dash.Dash(__name__)
app.layout = html.Div(
[
dcc.Input(
id=input_id(_), type=_, placeholder="input type {}".format(_)
)
for _ in ALLOWING_TYPES
]
+ [html.Div(id="output")]
)

@app.callback(
Output("output", "children"),
[Input(input_id(_), "value") for _ in ALLOWING_TYPES],
)
def cb_render(*vals):
return " | ".join((val for val in vals if val))

dash_duo.start_server(app)

assert (
dash_duo.find_element("#input_hidden").get_attribute("type")
== "hidden"
), "hidden input element should present with hidden type"

dash_duo.percy_snapshot("intp001 - init state")

for atype in ALLOWING_TYPES[:-1]:
dash_duo.find_element("#input_{}".format(atype)).send_keys(
"test intp001 - input[{}]".format(atype)
)

with pytest.raises(WebDriverException):
dash_duo.find_element("#input_hidden").send_keys("no interaction")

dash_duo.percy_snapshot("intp001 - callback output rendering")


def test_intp100_number_type(dash_duo):
app = dash.Dash(__name__)
app.layout = html.Div(
[
dcc.Input(
id="num",
type="number",
placeholder="this input is number type",
)
]
)

dash_duo.start_server(app)

num_input = dash_duo.find_element('#num')
assert not num_input.get_attribute('value')


0 comments on commit 49d979a

Please sign in to comment.