This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use start date, if one is supplied, for initial_visible_month. (#687)
* Use start_date or min_date_allowed for initial_visible_month if initial_visible_month is undefined. * Add test for initial month. * Add datePickerRange tests. * Use max date allowed * Make function call simpler. * Run linter. * Fix typo.
- Loading branch information
Shammamah Hossain
authored
Nov 6, 2019
1 parent
0e14498
commit e371b34
Showing
3 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from datetime import datetime | ||
|
||
import dash | ||
import dash_html_components as html | ||
import dash_core_components as dcc | ||
|
||
|
||
def test_dtpr001_initial_month_provided(dash_dcc): | ||
app = dash.Dash(__name__) | ||
app.layout = html.Div([ | ||
dcc.DatePickerRange( | ||
id="dps-initial-month", | ||
min_date_allowed=datetime(2010, 1, 1), | ||
max_date_allowed=datetime(2099, 12, 31), | ||
initial_visible_month=datetime(2019, 10, 28) | ||
) | ||
]) | ||
|
||
dash_dcc.start_server(app) | ||
|
||
date_picker_start = dash_dcc.find_element( | ||
'#dps-initial-month .DateInput_input.DateInput_input_1[placeholder="Start Date"]' | ||
) | ||
date_picker_start.click() | ||
|
||
dash_dcc.wait_for_text_to_equal( | ||
'#dps-initial-month .CalendarMonth.CalendarMonth_1[data-visible=true] strong', | ||
'October 2019', | ||
1 | ||
) | ||
|
||
|
||
def test_dtpr002_no_initial_month_min_date(dash_dcc): | ||
app = dash.Dash(__name__) | ||
app.layout = html.Div([ | ||
dcc.DatePickerRange( | ||
id="dps-initial-month", | ||
min_date_allowed=datetime(2010, 1, 1), | ||
max_date_allowed=datetime(2099, 12, 31) | ||
) | ||
]) | ||
|
||
dash_dcc.start_server(app) | ||
|
||
date_picker_start = dash_dcc.find_element( | ||
'#dps-initial-month .DateInput_input.DateInput_input_1[placeholder="Start Date"]' | ||
) | ||
date_picker_start.click() | ||
|
||
dash_dcc.wait_for_text_to_equal( | ||
'#dps-initial-month .CalendarMonth.CalendarMonth_1[data-visible=true] strong', | ||
'January 2010' | ||
) | ||
|
||
|
||
def test_dtpr003_no_initial_month_no_min_date_start_date(dash_dcc): | ||
app = dash.Dash(__name__) | ||
app.layout = html.Div([ | ||
dcc.DatePickerRange( | ||
id="dps-initial-month", | ||
start_date=datetime(2019, 8, 13), | ||
max_date_allowed=datetime(2099, 12, 31) | ||
) | ||
]) | ||
|
||
dash_dcc.start_server(app) | ||
|
||
date_picker_start = dash_dcc.find_element( | ||
'#dps-initial-month .DateInput_input.DateInput_input_1[placeholder="Start Date"]' | ||
) | ||
date_picker_start.click() | ||
|
||
dash_dcc.wait_for_text_to_equal( | ||
'#dps-initial-month .CalendarMonth.CalendarMonth_1[data-visible=true] strong', | ||
'August 2019' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters