attributeelement.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* bender-tags: treeview */
  6. 'use strict';
  7. import AttributeElement from '/ckeditor5/engine/treeview/attributeelement.js';
  8. import Element from '/ckeditor5/engine/treeview/element.js';
  9. import { DEFAULT_PRIORITY } from '/ckeditor5/engine/treeview/attributeelement.js';
  10. describe( 'AttributeElement', () => {
  11. describe( 'constructor', () => {
  12. it( 'should create element with default priority', () => {
  13. const el = new AttributeElement( 'strong' );
  14. expect( el ).to.be.an.instanceof( AttributeElement );
  15. expect( el ).to.be.an.instanceof( Element );
  16. expect( el ).to.have.property( 'name' ).that.equals( 'strong' );
  17. expect( el ).to.have.property( 'priority' ).that.equals( DEFAULT_PRIORITY );
  18. } );
  19. } );
  20. describe( 'clone', () => {
  21. it( 'should clone element with priority', () => {
  22. const el = new AttributeElement( 'b' );
  23. el.priority = 7;
  24. const clone = el.clone();
  25. expect( clone ).to.not.equal( el );
  26. expect( clone.name ).to.equal( el.name );
  27. expect( clone.priority ).to.equal( el.priority );
  28. } );
  29. } );
  30. describe( 'isSimilar', () => {
  31. it( 'should return true if priorities are the same', () => {
  32. const b1 = new AttributeElement( 'b' );
  33. b1.priority = 7;
  34. const b2 = new AttributeElement( 'b' );
  35. b2.priority = 7;
  36. expect( b1.isSimilar( b2 ) ).to.be.true;
  37. } );
  38. it( 'should return false if priorities are different', () => {
  39. const b1 = new AttributeElement( 'b' );
  40. b1.priority = 7;
  41. const b2 = new AttributeElement( 'b' ); // default priority
  42. expect( b1.isSimilar( b2 ) ).to.be.false;
  43. } );
  44. } );
  45. } );