|
@@ -3,12 +3,10 @@
|
|
|
* For licensing, see LICENSE.md.
|
|
* For licensing, see LICENSE.md.
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-import { getClosestListItem, getPositionBeforeBlock } from '../src/utils';
|
|
|
|
|
|
|
+import { getClosestListItem } from '../src/utils';
|
|
|
|
|
|
|
|
import Element from '@ckeditor/ckeditor5-engine/src/model/element';
|
|
import Element from '@ckeditor/ckeditor5-engine/src/model/element';
|
|
|
-import Text from '@ckeditor/ckeditor5-engine/src/model/text';
|
|
|
|
|
import Position from '@ckeditor/ckeditor5-engine/src/model/position';
|
|
import Position from '@ckeditor/ckeditor5-engine/src/model/position';
|
|
|
-import Schema from '@ckeditor/ckeditor5-engine/src/model/schema';
|
|
|
|
|
|
|
|
|
|
describe( 'getClosestListItem', () => {
|
|
describe( 'getClosestListItem', () => {
|
|
|
const item = new Element( 'listItem', null, 'foobar' );
|
|
const item = new Element( 'listItem', null, 'foobar' );
|
|
@@ -22,34 +20,3 @@ describe( 'getClosestListItem', () => {
|
|
|
expect( getClosestListItem( Position.createAt( root ) ) ).to.be.null;
|
|
expect( getClosestListItem( Position.createAt( root ) ) ).to.be.null;
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|
|
|
-
|
|
|
|
|
-describe( 'getPositionBeforeBlock', () => {
|
|
|
|
|
- const paragraph = new Element( 'paragraph', null, 'foo' );
|
|
|
|
|
- const item = new Element( 'listItem', null, 'bar' );
|
|
|
|
|
- const text = new Text( 'xyz' );
|
|
|
|
|
-
|
|
|
|
|
- const root = new Element( '$root' );
|
|
|
|
|
- root.appendChildren( [ paragraph, item, text ] );
|
|
|
|
|
-
|
|
|
|
|
- const schema = new Schema();
|
|
|
|
|
- schema.registerItem( 'paragraph', '$block' );
|
|
|
|
|
- schema.registerItem( 'listItem', '$block' );
|
|
|
|
|
-
|
|
|
|
|
- it( 'should return same position if position is already before a block', () => {
|
|
|
|
|
- const position = Position.createBefore( paragraph );
|
|
|
|
|
-
|
|
|
|
|
- expect( getPositionBeforeBlock( position, schema ).isEqual( position ) ).to.be.true;
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'should return position before position parent if position is inside a block', () => {
|
|
|
|
|
- const position = Position.createAt( item );
|
|
|
|
|
-
|
|
|
|
|
- expect( getPositionBeforeBlock( position, schema ).isEqual( Position.createBefore( item ) ) ).to.be.true;
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'should return null if position is not next to block and is not in a block other than root', () => {
|
|
|
|
|
- const position = Position.createBefore( text );
|
|
|
|
|
-
|
|
|
|
|
- expect( getPositionBeforeBlock( position, schema ) ).to.be.null;
|
|
|
|
|
- } );
|
|
|
|
|
-} );
|
|
|