insertdelta.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* bender-tags: treemodel, delta */
  6. 'use strict';
  7. import Document from '/ckeditor5/core/treemodel/document.js';
  8. import Element from '/ckeditor5/core/treemodel/element.js';
  9. import Position from '/ckeditor5/core/treemodel/position.js';
  10. describe( 'Batch', () => {
  11. let doc, root, batch, p, ul, chain;
  12. beforeEach( () => {
  13. doc = new Document();
  14. root = doc.createRoot( 'root' );
  15. root.insertChildren( 0, 'abc' );
  16. batch = doc.batch();
  17. p = new Element( 'p' );
  18. ul = new Element( 'ul' );
  19. chain = batch.insert( new Position( root, [ 2 ] ), [ p, ul ] );
  20. } );
  21. describe( 'insert', () => {
  22. it( 'should insert given nodes at given position', () => {
  23. expect( root.getChildCount() ).to.equal( 5 );
  24. expect( root.getChild( 2 ) ).to.equal( p );
  25. expect( root.getChild( 3 ) ).to.equal( ul );
  26. } );
  27. it( 'should be chainable', () => {
  28. expect( chain ).to.equal( batch );
  29. } );
  30. } );
  31. } );