-
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.
fix calendar-to-calendar dragging, incorrect triggers and args firing
- Loading branch information
Showing
2 changed files
with
108 additions
and
2 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
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { Calendar } from 'fullcalendar' | ||
import { getSingleEl } from '../event-render/EventRenderUtils' | ||
import { getDayEl } from '../view-render/DayGridRenderUtils' | ||
import { getRectCenter } from '../lib/geom' | ||
|
||
describe('dragging events between calendars', function() { | ||
let DEFAULT_DATE = '2019-01-01' | ||
let el0, el1 | ||
let calendar0, calendar1 | ||
|
||
beforeEach(function() { | ||
el0 = document.createElement('div') | ||
el1 = document.createElement('div') | ||
|
||
el0.style.width = el1.style.width = '50%' | ||
el0.style.cssFloat = el1.style.cssFloat = 'left' | ||
|
||
document.body.appendChild(el0) | ||
document.body.appendChild(el1) | ||
}) | ||
|
||
afterEach(function() { | ||
if (calendar0) { | ||
calendar0.destroy() | ||
} | ||
|
||
if (calendar1) { | ||
calendar1.destroy() | ||
} | ||
|
||
document.body.removeChild(el0) | ||
document.body.removeChild(el1) | ||
}) | ||
|
||
it('fires all triggers', function(done) { | ||
let triggerNames = [] | ||
|
||
calendar0 = new Calendar(el0, { | ||
timeZone: 'UTC', | ||
defaultDate: DEFAULT_DATE, | ||
defaultView: 'month', | ||
editable: true, | ||
events: [ | ||
{ start: '2019-01-01', id: 'a' } | ||
], | ||
eventLeave: function(info) { | ||
triggerNames.push('eventLeave') | ||
expect(info.draggedEl).toBe(eventEl) | ||
expect(info.event.id).toBe('a') | ||
} | ||
}) | ||
|
||
calendar1 = new Calendar(el1, { | ||
timeZone: 'UTC', | ||
defaultDate: DEFAULT_DATE, | ||
defaultView: 'month', | ||
editable: true, | ||
droppable: true, | ||
drop: function(info) { | ||
triggerNames.push('drop') | ||
expect(info.draggedEl).toBe(eventEl) | ||
expect(info.date).toEqualDate('2019-01-05') | ||
expect(info.dateStr).toBe('2019-01-05') | ||
expect(info.allDay).toBe(true) | ||
}, | ||
eventReceive: function(info) { | ||
triggerNames.push('eventReceive') | ||
expect(info.draggedEl).toBe(eventEl) | ||
expect(info.event.start).toEqualDate('2019-01-05') | ||
} | ||
}) | ||
|
||
calendar0.render() | ||
calendar1.render() | ||
|
||
let eventEl = getSingleEl()[0] | ||
let dayEl = getDayEl('2019-01-05')[1] // the one from the SECOND calendar | ||
let point0 = getRectCenter(eventEl.getBoundingClientRect()) | ||
let point1 = getRectCenter(dayEl.getBoundingClientRect()) | ||
|
||
$(eventEl).simulate('drag', { | ||
debug: true, | ||
point: point0, | ||
end: point1, | ||
callback: function() { | ||
expect(triggerNames).toEqual([ 'eventLeave', 'drop', 'eventReceive' ]) | ||
done() | ||
} | ||
}) | ||
}) | ||
|
||
}) |