|
|
@@ -3,18 +3,23 @@
|
|
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
|
*/
|
|
|
|
|
|
-import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
|
|
|
+/* globals document */
|
|
|
+
|
|
|
+import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
|
|
|
import ShiftEnter from '../src/shiftenter';
|
|
|
import ShiftEnterCommand from '../src/shiftentercommand';
|
|
|
import EnterObserver from '../src/enterobserver';
|
|
|
import DomEventData from '@ckeditor/ckeditor5-engine/src/view/observer/domeventdata';
|
|
|
|
|
|
describe( 'ShiftEnter feature', () => {
|
|
|
- let editor, viewDocument;
|
|
|
+ let element, editor, viewDocument;
|
|
|
|
|
|
beforeEach( () => {
|
|
|
- return VirtualTestEditor
|
|
|
- .create( {
|
|
|
+ element = document.createElement( 'div' );
|
|
|
+ document.body.appendChild( element );
|
|
|
+
|
|
|
+ return ClassicTestEditor
|
|
|
+ .create( element, {
|
|
|
plugins: [ ShiftEnter ]
|
|
|
} )
|
|
|
.then( newEditor => {
|
|
|
@@ -23,6 +28,11 @@ describe( 'ShiftEnter feature', () => {
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
+ afterEach( () => {
|
|
|
+ element.remove();
|
|
|
+ sinon.restore();
|
|
|
+ } );
|
|
|
+
|
|
|
it( 'creates the commands', () => {
|
|
|
expect( editor.commands.get( 'shiftEnter' ) ).to.be.instanceof( ShiftEnterCommand );
|
|
|
} );
|
|
|
@@ -44,6 +54,7 @@ describe( 'ShiftEnter feature', () => {
|
|
|
it( 'listens to the editing view enter event', () => {
|
|
|
const spy = editor.execute = sinon.spy();
|
|
|
const domEvt = getDomEvent();
|
|
|
+ sinon.stub( editor.editing.view, 'scrollToTheSelection' );
|
|
|
|
|
|
viewDocument.fire( 'enter', new DomEventData( viewDocument, domEvt, { isSoft: true } ) );
|
|
|
|