characterproxy.js 1.3 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: treemodel */
  6. 'use strict';
  7. import Node from '/ckeditor5/core/treemodel/node.js';
  8. import Element from '/ckeditor5/core/treemodel/element.js';
  9. import Text from '/ckeditor5/core/treemodel/text.js';
  10. import utils from '/ckeditor5/core/utils.js';
  11. describe( 'CharacterProxy', () => {
  12. let text, element, char;
  13. before( () => {
  14. text = new Text( 'abc', { foo: true } );
  15. element = new Element( 'div', [], [ new Element( 'p' ), text, new Element( 'p' ) ] );
  16. } );
  17. beforeEach( () => {
  18. char = element.getChild( 2 );
  19. } );
  20. it( 'should extend Node class', () => {
  21. expect( char ).to.be.instanceof( Node );
  22. } );
  23. it( 'should have correct character property', () => {
  24. expect( char ).to.have.property( 'character' ).that.equals( 'b' );
  25. } );
  26. it( 'should have correct parent property', () => {
  27. expect( char ).to.have.property( 'parent' ).that.equals( element );
  28. } );
  29. it( 'should have attributes list equal to passed to Text instance', () => {
  30. expect( utils.mapsEqual( char._attrs, text._attrs ) ).to.be.true;
  31. } );
  32. it( 'should return correct index in parent node', () => {
  33. expect( char.getIndex() ).to.equal( 2 );
  34. } );
  35. } );