-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Francesco Novy
committed
Jan 20, 2017
1 parent
d60c5fa
commit a37a58e
Showing
7 changed files
with
110 additions
and
0 deletions.
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,33 @@ | ||
import $ from 'jquery'; | ||
|
||
export const interactWithDatePicker = function(element) { | ||
let $el = $(element); | ||
let $button = $el.find('[data-test="date-picker-toggle-button"]'); | ||
|
||
return { | ||
buttonText() { | ||
return $button.text().trim(); | ||
}, | ||
|
||
toggle() { | ||
$button.click(); | ||
}, | ||
|
||
select(date) { | ||
$el.find(`button[data-test="day-${date.month()}-${date.date()}"]`).click(); | ||
}, | ||
|
||
nextMonth() { | ||
$el.find('.date-picker__header__button--next').click(); | ||
}, | ||
|
||
previousMonth() { | ||
$el.find('.date-picker__header__button--previous').click(); | ||
}, | ||
|
||
element: $el, | ||
buttonElement: $button | ||
}; | ||
}; | ||
|
||
export default interactWithDatePicker; |
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
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,28 @@ | ||
import Ember from 'ember'; | ||
import moment from 'moment'; | ||
|
||
const { | ||
Controller | ||
} = Ember; | ||
|
||
export default Controller.extend({ | ||
|
||
myOptions: ['clear', | ||
'today', | ||
'thisWeek', | ||
{ | ||
action: 'selectDateRange', | ||
label: 'Last 3 days', | ||
actionValue: [moment().startOf('day').subtract(3, 'days'), moment().startOf('day')] | ||
} | ||
], | ||
|
||
actions: { | ||
updateDateRange(vals) { | ||
console.log(vals); | ||
}, | ||
updateDate(val) { | ||
console.log(val); | ||
} | ||
} | ||
}); |
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,7 @@ | ||
import Ember from 'ember'; | ||
|
||
const { | ||
Route | ||
} = Ember; | ||
|
||
export default Route.extend({}); |
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,26 @@ | ||
{{title 'Testing'}} | ||
|
||
<h1>Testing</h1> | ||
|
||
<p> | ||
In integration & acceptance tests, a helper is provided to make working with the date picker easier. | ||
</p> | ||
|
||
{{#code-block | ||
language='javascript'}}import interactWithDatePicker from 'ember-date-components/helpers/interact-with-date-picker'; | ||
|
||
// Give the containing DOM element of the date picker as argument | ||
let datepicker = interactWithDatePicker(this.$('.date-picker__wrapper')); | ||
|
||
// Open/close the date picker | ||
datepicker.toggle(); | ||
|
||
// Try to select the provided date. If the date is not on the current page, this will do nothing | ||
datepicker.select(moment()); | ||
|
||
// Go to the next/previous month | ||
datepicker.nextMonth(); | ||
datepicker.previousMonth(); | ||
|
||
// The current text displayed on the date picker | ||
datepicker.buttonText();{{/code-block}} |