viewDestroy.js
1.31 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
describe('viewDestroy', function() {
var options;
beforeEach(function() {
options = {
defaultDate: '2015-02-20'
};
affix('#cal');
});
describe('when in month view', function() {
beforeEach(function() {
options = {
defaultView: 'month'
};
});
defineTests();
});
describe('when in agendaWeek view', function() {
beforeEach(function() {
options = {
defaultView: 'agendaWeek'
};
});
defineTests();
});
function defineTests() {
it('fires before the view is unrendered, with correct arguments', function(done) {
var viewRenderCalls = 0;
var viewDestroyCalls = 0;
options.viewRender = function() {
++viewRenderCalls;
};
options.viewDestroy = function(givenViewObj, givenViewEl) {
if (++viewDestroyCalls === 1) { // because done() calls destroy
// the viewDestroy should be called before the next viewRender
expect(viewRenderCalls).toBe(1);
var viewObj = $('#cal').fullCalendar('getView');
var viewEl = $('#cal .fc-view');
expect(viewObj).toBe(givenViewObj);
expect(viewEl[0]).toBe(givenViewEl[0]);
expect(viewEl.children().length >= 1).toBe(true); // is the content still rendered?
done();
}
};
$('#cal').fullCalendar(options);
$('#cal').fullCalendar('next'); // will trigger a viewDestroy/viewRender
});
}
});