character.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* bender-tags: treemodel */
  6. 'use strict';
  7. import Character from '/ckeditor5/core/treemodel/character.js';
  8. import Node from '/ckeditor5/core/treemodel/node.js';
  9. import Element from '/ckeditor5/core/treemodel/element.js';
  10. import Attribute from '/ckeditor5/core/treemodel/attribute.js';
  11. describe( 'Character', () => {
  12. describe( 'constructor', () => {
  13. it( 'should create character without attributes', () => {
  14. let character = new Character( 'f' );
  15. let parent = new Element( 'parent', [], character );
  16. expect( character ).to.be.an.instanceof( Node );
  17. expect( character ).to.have.property( 'character' ).that.equals( 'f' );
  18. expect( character ).to.have.property( 'parent' ).that.equals( parent );
  19. expect( character.attrs.size ).to.equal( 0 );
  20. } );
  21. it( 'should create character with attributes', () => {
  22. let attr = new Attribute( 'foo', 'bar' );
  23. let character = new Character( 'f', [ attr ] );
  24. let parent = new Element( 'parent', [], character );
  25. expect( character ).to.be.an.instanceof( Node );
  26. expect( character ).to.have.property( 'character' ).that.equals( 'f' );
  27. expect( character ).to.have.property( 'parent' ).that.equals( parent );
  28. expect( character.attrs.size ).to.equal( 1 );
  29. expect( character.attrs.get( attr.key ) ).to.equal( attr );
  30. } );
  31. } );
  32. } );