8
0

insertdelta.js 911 B

1234567891011121314151617181920212223242526272829303132333435363738
  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( 'Transaction', () => {
  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( [ 0 ], root );
  23. doc.createTransaction().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. } );