createroot.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  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. import { StylesProcessor } from '../../../src/view/stylesmap';
  9. describe( 'createRoot', () => {
  10. let viewDoc;
  11. beforeEach( () => {
  12. viewDoc = new Document( new StylesProcessor() );
  13. } );
  14. it( 'should create view root element with given data', () => {
  15. const root = createRoot( viewDoc, 'h1', 'header' );
  16. expect( root ).to.instanceof( RootAttributeElement );
  17. expect( root.name ).to.equal( 'h1' );
  18. expect( root.rootName ).to.equal( 'header' );
  19. } );
  20. it( 'should create view root element with default data', () => {
  21. const root = createRoot( viewDoc );
  22. expect( root ).to.instanceof( RootAttributeElement );
  23. expect( root.name ).to.equal( 'div' );
  24. expect( root.rootName ).to.equal( 'main' );
  25. } );
  26. it( 'should insert root element to view document roots collection', () => {
  27. const root = createRoot( viewDoc );
  28. expect( viewDoc.getRoot() ).to.equal( root );
  29. } );
  30. } );