-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,51 @@ | ||
|
||
// https://github.com/fullcalendar/fullcalendar/issues/4585 | ||
// more related to the 'more+' link than to async event sources | ||
it('rerendering works with async sources and eventLimit', function(done) { | ||
let cnt = 0 | ||
|
||
initCalendar({ | ||
defaultView: 'dayGridMonth', | ||
eventLimit: 2, | ||
header: { | ||
left: 'prev,next today', | ||
center: 'title', | ||
right: 'timeGridWeek,dayGridMonth' | ||
}, | ||
eventSources: [ | ||
getEvents, | ||
getEvents | ||
], | ||
_eventsPositioned() { // why can't use spyOnCalendarCallback :( | ||
cnt++ | ||
if (cnt === 1) { | ||
currentCalendar.next() | ||
setTimeout(done, 1) // after the async fetch | ||
describe('async event source rendering with eventLimit', function() { | ||
|
||
it('works', function(done) { | ||
let cnt = 0 | ||
|
||
initCalendar({ | ||
defaultView: 'dayGridMonth', | ||
eventLimit: 2, | ||
header: { | ||
left: 'prev,next today', | ||
center: 'title', | ||
right: 'timeGridWeek,dayGridMonth' | ||
}, | ||
eventSources: [ | ||
getEvents, | ||
getEvents | ||
], | ||
_eventsPositioned() { // why can't use spyOnCalendarCallback :( | ||
cnt++ | ||
if (cnt === 1) { | ||
currentCalendar.next() | ||
setTimeout(done, 1) // after the async fetch | ||
} | ||
} | ||
} | ||
}) | ||
}) | ||
}) | ||
|
||
function getEvents(fetchInfo, success) { | ||
let date = fetchInfo.start | ||
let events = [] | ||
function getEvents(fetchInfo, success) { | ||
let date = fetchInfo.start | ||
let events = [] | ||
|
||
while (date.getTime() < fetchInfo.end.getTime()) { | ||
events.push({ | ||
title: 'Event ' + date.getDate(), | ||
start: date, | ||
end: new Date(date.getTime() + 1000 * 60 * 60 * 60), | ||
allDay: false | ||
}) | ||
while (date.getTime() < fetchInfo.end.getTime()) { | ||
events.push({ | ||
title: 'Event ' + date.getDate(), | ||
start: date, | ||
end: new Date(date.getTime() + 1000 * 60 * 60 * 60), | ||
allDay: false | ||
}) | ||
|
||
date = new Date(date.getTime() + 1000 * 60 * 60 * 24) | ||
} | ||
|
||
date = new Date(date.getTime() + 1000 * 60 * 60 * 24) | ||
setTimeout(function() { | ||
success(events) | ||
}, 0) | ||
} | ||
|
||
setTimeout(function() { | ||
success(events) | ||
}, 0) | ||
} | ||
}) |