utils.js 798 B

12345678910111213141516171819202122
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import { getClosestListItem } from '../src/utils';
  6. import Element from '@ckeditor/ckeditor5-engine/src/model/element';
  7. import Position from '@ckeditor/ckeditor5-engine/src/model/position';
  8. describe( 'getClosestListItem', () => {
  9. const item = new Element( 'listItem', null, 'foobar' );
  10. const root = new Element( '$root', null, [ item ] );
  11. it( 'should return model listItem element if given position is in such element', () => {
  12. expect( getClosestListItem( Position.createAt( item ) ) ).to.equal( item );
  13. } );
  14. it( 'should return null if position is not in listItem', () => {
  15. expect( getClosestListItem( Position.createAt( root ) ) ).to.be.null;
  16. } );
  17. } );