character.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* jshint expr: true */
  6. /* bender-tags: document */
  7. 'use strict';
  8. var modules = bender.amd.require(
  9. 'document/character',
  10. 'document/node',
  11. 'document/element',
  12. 'document/attribute'
  13. );
  14. describe( 'Character', function() {
  15. var Element, Character, Node, Attribute;
  16. before( function() {
  17. Element = modules[ 'document/element' ];
  18. Character = modules[ 'document/character' ];
  19. Node = modules[ 'document/node' ];
  20. Attribute = modules[ 'document/attribute' ];
  21. } );
  22. describe( 'constructor', function() {
  23. it( 'should create character without attributes', function() {
  24. var character = new Character( 'f' );
  25. var parent = new Element( 'parent', [], character );
  26. expect( character ).to.be.an.instanceof( Node );
  27. expect( character ).to.have.property( 'character' ).that.equals( 'f' );
  28. expect( character ).to.have.property( 'parent' ).that.equals( parent );
  29. expect( character._getAttrCount() ).to.equal( 0 );
  30. } );
  31. it( 'should create character with attributes', function() {
  32. var attr = new Attribute( 'foo', 'bar' );
  33. var character = new Character( 'f', [ attr ] );
  34. var parent = new Element( 'parent', [], character );
  35. expect( character ).to.be.an.instanceof( Node );
  36. expect( character ).to.have.property( 'character' ).that.equals( 'f' );
  37. expect( character ).to.have.property( 'parent' ).that.equals( parent );
  38. expect( character._getAttrCount() ).to.equal( 1 );
  39. expect( character.getAttr( attr.key ) ).to.equal( attr.value );
  40. } );
  41. } );
  42. } );