Skip to content

Commit

Permalink
Fixes bendavis78#162 - Swipe to the next month doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsilva committed Nov 17, 2016
1 parent 6d5ade5 commit 71a69e2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"merge-stream": "^0.1.8",
"portfinder": "^0.4.0",
"vinyl-paths": "^1.0.0",
"web-component-tester": "^3.3.3"
"web-component-tester": "^5.0.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
4 changes: 3 additions & 1 deletion paper-calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@
}.bind(this));
},
_swipeNextMonth: function() {
if (!this.maxDate || this.currentMonth < this.maxDate.getMonth() + 1) {
if (!this.maxDate || moment([this.currentYear, this.currentMonth, 1]).isSameOrBefore(this.maxDate, 'month')) {
this._translateX(-this._containerWidth * 2, 'swipe', function() {
this.set('_contentClass', '');
this.transform('translateX(' + this._startPos + 'px)', this.$.months);
Expand Down Expand Up @@ -612,6 +612,8 @@
this.currentYear = year;
this.currentMonth = month;
}
console.log('ON SWIPE');
console.log(this.currentMonth);
},
_prevMonth: function() {
this._incrMonth(-1);
Expand Down
31 changes: 31 additions & 0 deletions test/paper-date-picker.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
</template>
</test-fixture>

<test-fixture id="max-date-on-next-year-fixture">
<template>
<paper-date-picker
id="picker"
date="November 1, 2016"
max-date="February 28, 2017">
</paper-date-picker>
</template>
</test-fixture>

<script>

describe('paper-date-picker', function() {
Expand Down Expand Up @@ -61,6 +71,27 @@

});

context('with max-date on next year', function () {
beforeEach(function() {
element = fixture('max-date-on-next-year-fixture');
});

it('should swipe until max date', function(done) {
// Try to swipe after the max bound
var calendar = element.$$('paper-calendar');
calendar._swipeNextMonth();
calendar._swipeNextMonth();
calendar._swipeNextMonth();
calendar._swipeNextMonth();

setTimeout(function() {
expect(calendar.currentMonth).to.equal(2);
expect(calendar.currentYear).to.equal(2017);
done();
}, 500);
});
});

});

</script>
Expand Down

0 comments on commit 71a69e2

Please sign in to comment.