insertdelta.js 954 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. /* bender-include: ../../_tools/tools.js */
  7. 'use strict';
  8. const modules = bender.amd.require(
  9. 'document/document',
  10. 'document/position' );
  11. describe( 'Transaction', () => {
  12. let Document, Position;
  13. let doc, root;
  14. before( () => {
  15. Document = modules[ 'document/document' ];
  16. Position = modules[ 'document/position' ];
  17. } );
  18. beforeEach( () => {
  19. doc = new Document();
  20. root = doc.createRoot( 'root' );
  21. } );
  22. it( 'should insert text', () => {
  23. const position = new Position( [ 0 ], root );
  24. doc.makeTransaction().insert( position, 'foo' );
  25. expect( root.getChildCount() ).to.equal( 3 );
  26. expect( root.getChild( 0 ).character ).to.equal( 'f' );
  27. expect( root.getChild( 1 ).character ).to.equal( 'o' );
  28. expect( root.getChild( 2 ).character ).to.equal( 'o' );
  29. } );
  30. } );