dayClick.js
4.76 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
describe('dayClick', function() {
var options;
beforeEach(function() {
affix('#cal');
options = {
defaultDate: '2014-05-27',
selectable: false
};
});
afterEach(function() {
$('#cal').fullCalendar('destroy');
});
[ false, true ].forEach(function(isRTL) {
describe('when isRTL is ' + isRTL, function() {
beforeEach(function() {
options.isRTL = isRTL;
});
[ false, true ].forEach(function(selectable) {
describe('when selectable is ' + selectable, function() {
beforeEach(function() {
options.selectable = selectable;
});
describe('when in month view', function() {
beforeEach(function() {
options.defaultView = 'month';
});
it('fires correctly when clicking on a cell', function(done) {
options.dayClick = function(date, jsEvent, view) {
expect(moment.isMoment(date)).toEqual(true);
expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
expect(typeof view).toEqual('object'); // "
expect(date.hasTime()).toEqual(false);
expect(date).toEqualMoment('2014-05-07');
};
spyOn(options, 'dayClick').and.callThrough();
$('#cal').fullCalendar(options);
var dayCell = $('.fc-day:eq(10)'); // 2014-05-07 (regardless of isRTL)
// for simulating the mousedown/mouseup/click (relevant for selectable)
dayCell.simulate('drag-n-drop', {
callback: function() {
dayCell.simulate('click');
expect(options.dayClick).toHaveBeenCalled();
done();
}
});
});
});
describe('when in agendaWeek view', function() {
beforeEach(function() {
options.defaultView = 'agendaWeek';
});
it('fires correctly when clicking on an all-day slot', function(done) {
options.dayClick = function(date, jsEvent, view) {
expect(moment.isMoment(date)).toEqual(true);
expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
expect(typeof view).toEqual('object'); // "
expect(date.hasTime()).toEqual(false);
expect(date).toEqualMoment('2014-05-28');
};
spyOn(options, 'dayClick').and.callThrough();
$('#cal').fullCalendar(options);
// 2014-05-28 (regardless of isRTL)
var dayContent = $('.fc-agenda-view .fc-day-grid .fc-day:eq(3)');
// for simulating the mousedown/mouseup/click (relevant for selectable)
dayContent.simulate('drag-n-drop', {
callback: function() {
dayContent.simulate('click');
expect(options.dayClick).toHaveBeenCalled();
done();
}
});
});
it('fires correctly when clicking on a timed slot', function(done) {
// make sure the click slot will be in scroll view
options.contentHeight = 500;
options.scrollTime = '07:00:00';
options.dayClick = function(date, jsEvent, view) {
expect(moment.isMoment(date)).toEqual(true);
expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
expect(typeof view).toEqual('object'); // "
expect(date.hasTime()).toEqual(true);
expect(date).toEqualMoment('2014-05-28T09:00:00');
};
spyOn(options, 'dayClick').and.callThrough();
$('#cal').fullCalendar(options);
// the middle is 2014-05-28T09:00:00 (regardless of isRTL)
var slotRow = $('.fc-slats tr:eq(18) td:not(.fc-time)');
// for simulating the mousedown/mouseup/click (relevant for selectable)
slotRow.simulate('drag-n-drop', {
callback: function() {
expect(options.dayClick).toHaveBeenCalled();
done();
}
});
});
// issue 2217
it('fires correctly when clicking on a timed slot, with minTime set', function(done) {
// make sure the click slot will be in scroll view
options.contentHeight = 500;
options.scrollTime = '07:00:00';
options.minTime = '02:00:00';
options.dayClick = function(date, jsEvent, view) {
expect(moment.isMoment(date)).toEqual(true);
expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
expect(typeof view).toEqual('object'); // "
expect(date.hasTime()).toEqual(true);
expect(date).toEqualMoment('2014-05-28T11:00:00');
};
spyOn(options, 'dayClick').and.callThrough();
$('#cal').fullCalendar(options);
// the middle is 2014-05-28T11:00:00 (regardless of isRTL)
var slotRow = $('.fc-slats tr:eq(18) td:not(.fc-time)');
// for simulating the mousedown/mouseup/click (relevant for selectable)
slotRow.simulate('drag-n-drop', {
callback: function() {
expect(options.dayClick).toHaveBeenCalled();
done();
}
});
});
});
});
});
});
});
});