insertdelta.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* bender-tags: treemodel, delta */
  6. 'use strict';
  7. const modules = bender.amd.require(
  8. 'treemodel/document',
  9. 'treemodel/element',
  10. 'treemodel/position',
  11. 'treemodel/delta/insertdelta'
  12. );
  13. describe( 'Batch', () => {
  14. let Document, Element, Position, InsertDelta;
  15. before( () => {
  16. Document = modules[ 'treemodel/document' ];
  17. Element = modules[ 'treemodel/element' ];
  18. Position = modules[ 'treemodel/position' ];
  19. InsertDelta = modules[ 'treemodel/delta/insertdelta' ];
  20. } );
  21. let doc, root, batch, p, ul, chain;
  22. beforeEach( () => {
  23. doc = new Document();
  24. root = doc.createRoot( 'root' );
  25. root.insertChildren( 0, 'abc' );
  26. batch = doc.batch();
  27. p = new Element( 'p' );
  28. ul = new Element( 'ul' );
  29. chain = batch.insert( new Position( root, [ 2 ] ), [ p, ul ] );
  30. } );
  31. describe( 'insert', () => {
  32. it( 'should insert given nodes at given position', () => {
  33. expect( root.getChildCount() ).to.equal( 5 );
  34. expect( root.getChild( 2 ) ).to.equal( p );
  35. expect( root.getChild( 3 ) ).to.equal( ul );
  36. } );
  37. it( 'should be chainable', () => {
  38. expect( chain ).to.equal( batch );
  39. } );
  40. } );
  41. } );