-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathtest.html
169 lines (159 loc) · 4.23 KB
/
test.html
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>fullcalendar-rightclick.js qUnit test</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.9.1.css">
<script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.js'></script>
<script src='https://code.jquery.com/jquery-2.1.3.js'></script>
<link href='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.9.0/fullcalendar.css' rel='stylesheet' />
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="https://code.jquery.com/qunit/qunit-2.9.1.js"></script>
</body>
</html>
<script>
var versions = [
'3.10.0',
'3.9.0',
'3.8.2',
'3.8.1',
'3.8.0',
'3.7.0',
'3.6.2',
'3.6.1',
'3.6.0',
'3.5.1',
'3.5.0',
'3.4.0',
'3.3.1',
'3.3.0',
'3.2.0',
'3.1.0',
'3.0.1',
'3.0.0',
'2.9.1',
'2.9.0',
'2.8.0',
'2.7.3',
'2.7.2',
'2.7.1',
'2.7.0',
'2.6.1',
'2.6.0',
'2.5.0',
'2.4.0',
'2.3.2',
'2.3.1',
'2.3.0',
];
function loadScript(filename) {
return new Promise(function (resolve, reject) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.onload = resolve;
script.onerror = reject;
script.src = filename;
document.getElementsByTagName("head")[0].appendChild(script);
});
}
function setVersion(version) {
delete window.FullCalendar;
delete jQuery.fullCalendar;
return loadScript("https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/" + version + "/fullcalendar.js");
}
function simulateRightClickEvent(el) {
var ev = jQuery.Event("contextmenu");
el.find(".fc-event").trigger(ev);
}
function simulateRightClickDay(el, x, y) {
var ev = jQuery.Event("contextmenu");
if (x && y) {
// qUnit fixture is located 10000 px off screen in X and Y coordinates
ev.pageX = x - 10000;
ev.pageY = y - 10000;
}
el.find(".fc-day").trigger(ev);
}
versions.forEach(function(version) {
var ctx = {
dayRightclick: null,
eventRightclick: null,
month: null,
week: null,
day: null,
}
function newCalendar(view) {
var el = $('#qunit-fixture').append('<div></div>');
el.fullCalendar({
dayRightclick: function(date, jsEvent, view) {
ctx.dayRightclick(date, jsEvent, view);
return false;
},
eventRightclick: function(event, jsEvent, view) {
ctx.eventRightclick(event, jsEvent, view);
return false;
},
defaultDate: '2015-02-01',
defaultView: view,
editable: true,
eventLimit: true,
events: [
{
title: 'All Day Event',
start: '2015-02-01'
},
],
})
return el;
}
QUnit.module('FullCalendar version: ' + version, {
before: function() {
return setVersion(version).then(function() {
return loadScript("fullcalendar-rightclick.js");
});
},
beforeEach: function() {
ctx.eventRightclick = ctx.dayRightclick = function(date, jsEvent, view) {
throw new Error("Event not intercepted");
}
}
}, function() {
QUnit.test('loads', function(assert) {
let v = version;
// For whatever reason, it looks like FullCalendar
// didn't run the templater for these versions,
// so the release has the tag instead of the version.
if (v === '2.9.1') {
v = '<%= meta.version %>';
} if (v === '3.7.0') {
v = '<%= version %>';
}
assert.equal(jQuery.fullCalendar.version, v);
});
[ 'month', 'basicWeek', 'basicDay', 'agendaWeek', 'agendaDay' ].forEach(function(view) {
QUnit.test('right-click on day in ' + view + ' view', function(assert) {
var done = assert.async();
ctx.dayRightclick = function(date) {
assert.ok(moment.isMoment(date), 'receives the date')
done();
}
// 235x360 is a location on the calendar that's not on an event.
simulateRightClickDay(newCalendar(view), 235, 360);
})
QUnit.test('right-click on event in ' + view + ' view', function(assert) {
var done = assert.async();
ctx.eventRightclick = function(event) {
assert.equal(typeof event, 'object', 'receives the event object');
assert.equal(typeof event.title, 'string', 'event object has title');
done();
}
simulateRightClickEvent(newCalendar(view));
})
})
});
});
</script>