custom-view-class.js
2.04 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
describe('custom view class', function() {
beforeEach(function() {
affix('#cal');
});
it('calls all standard methods with correct parameters', function() {
var FC = $.fullCalendar;
var View = FC.View;
var CustomView;
var methods = {
initialize: function() {
},
render: function() {
},
setHeight: function(height, isAuto) {
expect(typeof height).toBe('number');
expect(typeof isAuto).toBe('boolean');
},
renderEvents: function(events) {
expect($.type(events)).toBe('array');
expect(events.length).toBe(1);
expect(moment.isMoment(events[0].start)).toBe(true);
expect(moment.isMoment(events[0].end)).toBe(true);
},
destroyEvents: function() {
},
renderSelection: function(range) {
expect($.type(range)).toBe('object');
expect(moment.isMoment(range.start)).toBe(true);
expect(moment.isMoment(range.end)).toBe(true);
},
destroySelection: function() {
}
};
spyOn(methods, 'initialize').and.callThrough();
spyOn(methods, 'render').and.callThrough();
spyOn(methods, 'setHeight').and.callThrough();
spyOn(methods, 'renderEvents').and.callThrough();
spyOn(methods, 'destroyEvents').and.callThrough();
spyOn(methods, 'renderSelection').and.callThrough();
spyOn(methods, 'destroySelection').and.callThrough();
CustomView = View.extend(methods);
FC.views.custom = CustomView;
$('#cal').fullCalendar({
defaultView: 'custom',
events: [
{
title: 'Holidays',
start: '2014-12-24',
end: '2014-12-26'
}
]
});
expect(methods.initialize).toHaveBeenCalled();
expect(methods.render).toHaveBeenCalled();
expect(methods.setHeight).toHaveBeenCalled();
expect(methods.renderEvents).toHaveBeenCalled();
$('#cal').fullCalendar('rerenderEvents');
expect(methods.destroyEvents).toHaveBeenCalled();
$('#cal').fullCalendar('select', '2014-12-25', '2014-01-01');
expect(methods.renderSelection).toHaveBeenCalled();
$('#cal').fullCalendar('unselect');
expect(methods.destroySelection).toHaveBeenCalled();
delete FC.views.custom;
});
});