8
0

insertdelta.js 1.1 KB

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