-
-
Notifications
You must be signed in to change notification settings - Fork 144
772 set href as a required prop and as the default value for children #776
Changes from 10 commits
cc0f0cc
efbdd4c
738ed20
86ad1fa
dd1a95e
89ed2c0
4d966f5
40b9502
4537402
5f7e930
da999d5
065c462
fc5d694
5eac66e
5a53fc2
fa29fcf
07a736c
06d39e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import pytest | ||
import dash | ||
from dash.dependencies import Input, Output | ||
import dash_core_components as dcc | ||
import dash_html_components as html | ||
|
||
|
||
@pytest.mark.DCC776 | ||
def test_lich001_default(dash_dcc): | ||
app = dash.Dash(__name__) | ||
app.layout = html.Div( | ||
[ | ||
dcc.Link(id="link1", href="/page-1"), | ||
dcc.Location(id="url", refresh=False), | ||
html.Div(id="content") | ||
] | ||
) | ||
@app.callback(Output("content", "children"), [Input("link1", "children")]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this callback and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add another simple test checking that children are indeed children when defined There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 5eac66e. |
||
def display_children(children): | ||
return children | ||
|
||
dash_dcc.start_server(app) | ||
|
||
href_as_children = dash_dcc.driver.execute_script( | ||
''' | ||
return document.getElementById("link1").text; | ||
''' | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 4537402. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That statement replaces the whole There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm guessing that method acts as a wrapper of sorts to check the text? Interesting. Updated in da999d5. |
||
|
||
dash_dcc.wait_for_text_to_equal("#link1", "/page-1") | ||
|
||
assert href_as_children == "/page-1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're golfing - add
children
to the destructuring ofthis.props
above (href
is already there) and this collapses to just{isNil(children) ? href : children}
That's a nicer pattern anyway, as it shows up front what props get used during the render.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, destructuring does look cleaner. Updated in 065c462.