|
@@ -10,6 +10,7 @@ import MoveOperation from '../../../src/model/operation/moveoperation';
|
|
|
import Position from '../../../src/model/position';
|
|
import Position from '../../../src/model/position';
|
|
|
import Text from '../../../src/model/text';
|
|
import Text from '../../../src/model/text';
|
|
|
import Element from '../../../src/model/element';
|
|
import Element from '../../../src/model/element';
|
|
|
|
|
+import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
|
import { jsonParseStringify, wrapInDelta } from '../../../tests/model/_utils/utils';
|
|
import { jsonParseStringify, wrapInDelta } from '../../../tests/model/_utils/utils';
|
|
|
|
|
|
|
|
describe( 'RemoveOperation', () => {
|
|
describe( 'RemoveOperation', () => {
|
|
@@ -140,6 +141,25 @@ describe( 'RemoveOperation', () => {
|
|
|
expect( doc.graveyard.getChild( 2 ).name ).to.equal( 'y' );
|
|
expect( doc.graveyard.getChild( 2 ).name ).to.equal( 'y' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
|
|
+ it( 'should throw when is executed on detached item', () => {
|
|
|
|
|
+ const batch = doc.batch();
|
|
|
|
|
+ const docFrag = batch.createDocumentFragment();
|
|
|
|
|
+ const item = batch.createElement( 'foo' );
|
|
|
|
|
+
|
|
|
|
|
+ batch.append( item, docFrag );
|
|
|
|
|
+
|
|
|
|
|
+ const op = new RemoveOperation(
|
|
|
|
|
+ new Position( docFrag, [ 0 ] ),
|
|
|
|
|
+ 1,
|
|
|
|
|
+ new Position( doc.graveyard, [ 0 ] ),
|
|
|
|
|
+ doc.version
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ expect( () => {
|
|
|
|
|
+ op._execute();
|
|
|
|
|
+ } ).to.throw( CKEditorError, /^remove-operation-on-detached-item/ );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
it( 'should always be a document operation', () => {
|
|
it( 'should always be a document operation', () => {
|
|
|
const op = new RemoveOperation(
|
|
const op = new RemoveOperation(
|
|
|
new Position( root, [ 2 ] ),
|
|
new Position( root, [ 2 ] ),
|