character.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. describe( 'Character', function() {
  14. var Element, Character, Node, Attribute;
  15. before( function() {
  16. Element = modules[ 'document/element' ];
  17. Character = modules[ 'document/character' ];
  18. Node = modules[ 'document/node' ];
  19. Attribute = modules[ 'document/attribute' ];
  20. } );
  21. describe( 'constructor', function() {
  22. it( 'should create character without attributes', function() {
  23. var character = new Character( 'f' );
  24. var 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._getAttrCount() ).to.equal( 0 );
  29. } );
  30. it( 'should create character with attributes', function() {
  31. var attr = new Attribute( 'foo', 'bar' );
  32. var character = new Character( 'f', [ attr ] );
  33. var parent = new Element( 'parent', [], character );
  34. expect( character ).to.be.an.instanceof( Node );
  35. expect( character ).to.have.property( 'character' ).that.equals( 'f' );
  36. expect( character ).to.have.property( 'parent' ).that.equals( parent );
  37. expect( character._getAttrCount() ).to.equal( 1 );
  38. expect( character.getAttr( attr.key ) ).to.equal( attr.value );
  39. } );
  40. } );
  41. } );