Skip to content

Commit

Permalink
Tests: Dragstart and dragend have the same target now.
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Jasiun authored and Reinmar committed Jun 3, 2015
1 parent f580eef commit f81468f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
20 changes: 7 additions & 13 deletions tests/plugins/widget/dnd.js
Expand Up @@ -67,15 +67,11 @@
dropTarget.fire( 'drop', evt );
}

function dragend( editor, evt, dropRange ) {
function dragend( editor, evt, widget ) {
var dropTarget = CKEDITOR.env.ie && CKEDITOR.env.version < 9 ? editor.editable() : editor.document;

// If drop range is known use a realistic target. If no, then use a mock.
if ( dropRange ) {
evt.setTarget( dropRange.startContainer );
} else {
evt.setTarget( new CKEDITOR.dom.text( 'targetMock' ) );
}
// Use realistic target which is the drag handler.
evt.setTarget( widget.dragHandlerContainer.findOne( 'img' ) );

dropTarget.fire( 'dragend', evt );
}
Expand Down Expand Up @@ -278,7 +274,7 @@

drop( editor, evt );

dragend( editor, evt );
dragend( editor, evt, widget );

assert.areSame( '<p><span data-widget="testwidget" id="w1">foo</span></p>', editor.getData() );
assert.areSame( 0, widgetWasDestroyed, 'Original widget should not be destroyed' );
Expand All @@ -302,8 +298,6 @@

drop( editor, evt.data );

dragend( editor, evt.data );

assert.areSame( '<p><span data-widget="testwidget" id="w1">foo</span></p>', editor.getData() );
assert.areSame( 0, widgetWasDestroyed, 'Original widget should not be destroyed' );
} );
Expand All @@ -330,7 +324,7 @@

drop( editor, evt.data );

dragend( editor, evt.data );
dragend( editor, evt.data, widget );

wait( function() {
assert.areSame( '<p><span data-widget="testwidget" id="w1">foo</span></p>', editor.getData() );
Expand Down Expand Up @@ -387,7 +381,7 @@

drop( editor, evt.data, range );

dragend( editor, evt.data, range );
dragend( editor, evt.data, widget );
} );
} );
},
Expand Down Expand Up @@ -420,7 +414,7 @@

drop( editor, evt.data, range );

dragend( editor, evt.data, range );
dragend( editor, evt.data, widget );
} );
} );
},
Expand Down
2 changes: 2 additions & 0 deletions tests/plugins/widget/undo.js
Expand Up @@ -353,6 +353,8 @@
evt.testRange = range;
dropTarget.fire( 'drop', evt );

evt.setTarget( editor.document.findOne( 'img.cke_widget_drag_handler' ) );
evt.testRange = undefined;
dropTarget.fire( 'dragend', evt );
} );
} );
Expand Down

0 comments on commit f81468f

Please sign in to comment.