createroot.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import Document from '../../../src/view/document.js';
  6. import RootAttributeElement from '../../../src/view/rooteditableelement.js';
  7. import createRoot from '../_utils/createroot.js';
  8. describe( 'createRoot', () => {
  9. let viewDoc;
  10. beforeEach( () => {
  11. viewDoc = new Document();
  12. } );
  13. it( 'should create view root element with given data', () => {
  14. const root = createRoot( viewDoc, 'h1', 'header' );
  15. expect( root ).to.instanceof( RootAttributeElement );
  16. expect( root.name ).to.equal( 'h1' );
  17. expect( root.rootName ).to.equal( 'header' );
  18. } );
  19. it( 'should create view root element with default data', () => {
  20. const root = createRoot( viewDoc );
  21. expect( root ).to.instanceof( RootAttributeElement );
  22. expect( root.name ).to.equal( 'div' );
  23. expect( root.rootName ).to.equal( 'main' );
  24. } );
  25. it( 'should insert root element to view document roots collection', () => {
  26. const root = createRoot( viewDoc );
  27. expect( viewDoc.getRoot() ).to.equal( root );
  28. } );
  29. } );