eventLimitClick.js
3.85 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
describe('eventLimitClick', function() { // simulate a click
var options;
beforeEach(function() {
affix('#cal');
options = {
defaultDate: '2014-08-01', // important that it is the first week, so works w/ month + week views
defaultView: 'month',
eventLimit: 3,
events: [
{ title: 'event1', start: '2014-07-29' },
{ title: 'event2', start: '2014-07-29' },
{ title: 'event2', start: '2014-07-29' },
{ title: 'event2', start: '2014-07-29' }
]
};
});
describe('when set to "popover"', function() {
beforeEach(function() {
options.eventLimitClick = 'popover';
});
it('renders a popover upon click', function() {
$('#cal').fullCalendar(options);
$('.fc-more').simulate('click');
expect($('.fc-more-popover')).toBeVisible();
});
// more popover tests are done in eventLimit-popover
});
describe('when set to "week"', function() {
beforeEach(function() {
options.eventLimitClick = 'week';
});
it('should go to basicWeek if it is one of the available views', function() {
options.header = {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
};
$('#cal').fullCalendar(options);
$('.fc-more').simulate('click');
var view = $('#cal').fullCalendar('getView');
expect(view.name).toBe('basicWeek'); // .name should be deprecated
expect(view.type).toBe('basicWeek');
});
it('should go to agendaWeek if it is one of the available views', function() {
options.header = {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
};
$('#cal').fullCalendar(options);
$('.fc-more').simulate('click');
var view = $('#cal').fullCalendar('getView');
expect(view.name).toBe('agendaWeek'); // .name should be deprecated
expect(view.type).toBe('agendaWeek');
});
});
describe('when set to "day"', function() {
beforeEach(function() {
options.eventLimitClick = 'day';
});
it('should go to basicDay if it is one of the available views', function() {
options.header = {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
};
$('#cal').fullCalendar(options);
$('.fc-more').simulate('click');
var view = $('#cal').fullCalendar('getView');
expect(view.name).toBe('basicDay');
});
it('should go to agendaDay if it is one of the available views', function() {
options.header = {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
};
$('#cal').fullCalendar(options);
$('.fc-more').simulate('click');
var view = $('#cal').fullCalendar('getView');
expect(view.name).toBe('agendaDay');
});
});
it('works with an explicit view name', function() {
options.eventLimitClick = 'agendaWeek';
options.header = {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
};
$('#cal').fullCalendar(options);
$('.fc-more').simulate('click');
var view = $('#cal').fullCalendar('getView');
expect(view.name).toBe('agendaWeek');
});
it('works with custom function and all the arguments are correct', function() {
options.eventLimitClick = function(cellInfo, jsEvent) {
expect(typeof cellInfo).toBe('object');
expect(typeof jsEvent).toBe('object');
expect(cellInfo.date).toEqualMoment('2014-07-29');
expect(cellInfo.dayEl.data('date')).toBe('2014-07-29');
expect(cellInfo.hiddenSegs.length).toBe(2);
expect(cellInfo.segs.length).toBe(4);
expect(cellInfo.moreEl).toHaveClass('fc-more');
};
$('#cal').fullCalendar(options);
$('.fc-more').simulate('click');
});
it('works with custom function, and can return a view name', function() {
options.eventLimitClick = function(cellInfo, jsEvent) {
return 'agendaDay';
};
$('#cal').fullCalendar(options);
$('.fc-more').simulate('click');
var view = $('#cal').fullCalendar('getView');
expect(view.name).toBe('agendaDay');
});
});