rootelement.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import Document from '../../src/model/document';
  6. import Element from '../../src/model/element';
  7. import RootElement from '../../src/model/rootelement';
  8. import count from '@ckeditor/ckeditor5-utils/src/count';
  9. describe( 'RootElement', () => {
  10. describe( 'constructor()', () => {
  11. it( 'should create root element without attributes', () => {
  12. const doc = new Document();
  13. const root = new RootElement( doc );
  14. expect( root ).to.be.an.instanceof( Element );
  15. expect( root ).to.have.property( 'document' ).that.equals( doc );
  16. expect( count( root.getAttributes() ) ).to.equal( 0 );
  17. expect( root.childCount ).to.equal( 0 );
  18. } );
  19. } );
  20. describe( 'is', () => {
  21. let root;
  22. before( () => {
  23. const doc = new Document();
  24. root = new RootElement( doc, '$root' );
  25. } );
  26. it( 'should return true for rootElement, element, element with same name and element name', () => {
  27. expect( root.is( 'element', '$root' ) ).to.be.true;
  28. expect( root.is( 'element' ) ).to.be.true;
  29. expect( root.is( '$root' ) ).to.be.true;
  30. expect( root.is( 'rootElement', '$root' ) ).to.be.true;
  31. expect( root.is( 'rootElement' ) ).to.be.true;
  32. } );
  33. it( 'should return false for other accept values', () => {
  34. expect( root.is( 'element', '$graveyard' ) ).to.be.false;
  35. expect( root.is( 'rootElement', '$graveyard' ) ).to.be.false;
  36. expect( root.is( '$graveyard' ) ).to.be.false;
  37. expect( root.is( 'text' ) ).to.be.false;
  38. expect( root.is( 'textProxy' ) ).to.be.false;
  39. expect( root.is( 'documentFragment' ) ).to.be.false;
  40. } );
  41. } );
  42. } );