8
0

characterproxy.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. const modules = bender.amd.require(
  8. 'core/treemodel/node',
  9. 'core/treemodel/element',
  10. 'core/treemodel/text',
  11. 'core/treemodel/attribute'
  12. );
  13. describe( 'CharacterProxy', () => {
  14. let Node, Element, Text, Attribute;
  15. let text, element, char;
  16. before( () => {
  17. Node = modules[ 'core/treemodel/node' ];
  18. Element = modules[ 'core/treemodel/element' ];
  19. Text = modules[ 'core/treemodel/text' ];
  20. Attribute = modules[ 'core/treemodel/attribute' ];
  21. text = new Text( 'abc', [ new Attribute( 'foo', true ) ] );
  22. element = new Element( 'div', [], [ new Element( 'p' ), text, new Element( 'p' ) ] );
  23. } );
  24. beforeEach( () => {
  25. char = element.getChild( 2 );
  26. } );
  27. it( 'should extend Node class', () => {
  28. expect( char ).to.be.instanceof( Node );
  29. } );
  30. it( 'should have correct character property', () => {
  31. expect( char ).to.have.property( 'character' ).that.equals( 'b' );
  32. } );
  33. it( 'should have correct parent property', () => {
  34. expect( char ).to.have.property( 'parent' ).that.equals( element );
  35. } );
  36. it( 'should have attributes list equal to passed to Text instance', () => {
  37. expect( char.attrs.isEqual( text.attrs ) ).to.be.true;
  38. } );
  39. it( 'should return correct index in parent node', () => {
  40. expect( char.getIndex() ).to.equal( 2 );
  41. } );
  42. } );