paper-date-picker.html
1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="../bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<script src="../bower_components/web-component-tester/browser.js"></script>
<!-- import the element to test -->
<link rel="import" href="../paper-date-picker.html">
</head>
<body>
<test-fixture id="max-date-fixture">
<template>
<paper-date-picker
id="picker"
date="January 1, 2016"
max-date="February 28, 2016">
</paper-date-picker>
</template>
</test-fixture>
<script>
describe('paper-date-picker', function() {
var element;
context('with a max-date', function() {
beforeEach(function() {
element = fixture('max-date-fixture');
});
it('should not swipe after the max bound', function(done) {
// Check initialization
expect(element.date).to.be.not.null;
expect(element.maxDate).to.be.not.null;
// Try to swipe after the max bound
var calendar = element.$$('paper-calendar');
calendar._swipeNextMonth();
calendar._swipeNextMonth();
calendar._swipeNextMonth();
calendar._swipeNextMonth();
// Check after all animation that the calendar has been transformed
// once
setTimeout(function() {
// When the max bound is reached, the div `months` contains only two
// months. So we check that the current position is equal to the
// half of the width, else it means the calendar has undergone too
// much transformations
expect(calendar._currentPos).to.equal(
-(calendar.$.months.clientWidth / 2)
);
done();
}, 500);
});
});
});
</script>
</body>
</html>