Skip to content

Commit

Permalink
change structure of test
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Apr 23, 2019
1 parent f73e754 commit a652f27
Showing 1 changed file with 41 additions and 37 deletions.
78 changes: 41 additions & 37 deletions tests/automated/event-source/async-eventLimit.js
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)
}
})

0 comments on commit a652f27

Please sign in to comment.