Skip to content

Commit

Permalink
forceEventDuration works with external events. fixes #4597
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Apr 2, 2019
1 parent f27c39f commit a4252ce
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function computeEventForDateSpan(dateSpan: DateSpan, dragMeta: DragMeta, calenda
defProps,
dragMeta.sourceId,
dateSpan.allDay,
Boolean(dragMeta.duration), // hasEnd
calendar.opt('forceEventDuration') || Boolean(dragMeta.duration), // hasEnd
calendar
)

Expand Down
55 changes: 55 additions & 0 deletions tests/automated/event-drag/from-external.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Draggable } from '@fullcalendar/interaction'
import { getDayEl } from '../view-render/DayGridRenderUtils'

describe('external event dragging', function() {
var $dragEl
var thirdPartyDraggable

beforeEach(function() {
$dragEl = $('<div class="drag">yo</div>')
.css({
width: 200,
background: 'blue',
color: 'white'
})
.appendTo('body')
})

afterEach(function() {
if (thirdPartyDraggable) {
thirdPartyDraggable.destroy()
}
$dragEl.remove()
$dragEl = null
})


describe('with forceEventDuration', function() {
pushOptions({
forceEventDuration: true,
defaultEventDuration: '1:30'
})

it('should yield an event with an end', function(done) {
initCalendar({
defaultView: 'dayGridMonth',
defaultDate: '2019-04-01',
droppable: true,
defaultAllDayEventDuration: { days: 2 },
eventReceive(arg) {
expect(arg.event.end).toEqualDate('2019-04-04')
done()
}
})

thirdPartyDraggable = new Draggable($dragEl[0], {
eventData: {}
})

$dragEl.simulate('drag', {
end: getDayEl('2019-04-02')
})
})
})

})

0 comments on commit a4252ce

Please sign in to comment.