rooteditableelement.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import ContainerElement from 'ckeditor5-engine/src/view/containerelement';
  6. import EditableElement from 'ckeditor5-engine/src/view/editableelement';
  7. import RootEditableElement from 'ckeditor5-engine/src/view/rooteditableelement';
  8. import createDocumentMock from 'ckeditor5-engine/tests/view/_utils/createdocumentmock';
  9. describe( 'RootEditableElement', () => {
  10. describe( 'constructor()', () => {
  11. it( 'should create an element with default root name', () => {
  12. const root = new RootEditableElement( 'div' );
  13. root.document = createDocumentMock();
  14. expect( root ).to.be.instanceof( EditableElement );
  15. expect( root ).to.be.instanceof( ContainerElement );
  16. expect( root.rootName ).to.equal( 'main' );
  17. expect( root.name ).to.equal( 'div' );
  18. expect( root.isFocused ).to.be.false;
  19. expect( root.isReadOnly ).to.be.false;
  20. } );
  21. it( 'should create an element with custom root name', () => {
  22. const root = new RootEditableElement( 'h1' );
  23. root.document = createDocumentMock();
  24. root.rootName = 'header';
  25. expect( root.rootName ).to.equal( 'header' );
  26. expect( root.name ).to.equal( 'h1' );
  27. expect( root.isFocused ).to.be.false;
  28. expect( root.isReadOnly ).to.be.false;
  29. } );
  30. } );
  31. it( 'should be cloned properly', () => {
  32. const root = new RootEditableElement( 'h1' );
  33. root.document = createDocumentMock();
  34. root.rootName = 'header';
  35. const newRoot = root.clone();
  36. expect( newRoot.document ).to.equal( root.document );
  37. expect( newRoot.rootName ).to.equal( root.rootName );
  38. } );
  39. } );