editoruiview.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. /* global document */
  6. import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
  7. import EditorUIView from '../../src/editorui/editoruiview';
  8. import ViewCollection from '../../src/viewcollection';
  9. import Locale from '@ckeditor/ckeditor5-utils/src/locale';
  10. describe( 'EditorUIView', () => {
  11. let view, locale;
  12. testUtils.createSinonSandbox();
  13. beforeEach( () => {
  14. locale = new Locale();
  15. view = new EditorUIView( locale );
  16. view.render();
  17. } );
  18. afterEach( () => {
  19. view.destroy();
  20. } );
  21. describe( 'constructor()', () => {
  22. it( 'accepts locale', () => {
  23. expect( view.locale ).to.equal( locale );
  24. } );
  25. it( 'sets all the properties', () => {
  26. expect( view.body ).to.be.instanceof( ViewCollection );
  27. } );
  28. } );
  29. describe( 'render()', () => {
  30. it( 'attach the body collection', () => {
  31. expect( view.body._bodyCollectionContainer.parentNode.classList.contains( 'ck-body-wrapper' ) ).to.be.true;
  32. expect( view.body._bodyCollectionContainer.parentNode.parentNode ).to.equal( document.body );
  33. } );
  34. } );
  35. describe( 'destroy()', () => {
  36. it( 'detach the body collection', () => {
  37. const el = view.body._bodyCollectionContainer;
  38. view.destroy();
  39. expect( el.parentNode ).to.be.null;
  40. } );
  41. it( 'can be called multiple times', () => {
  42. expect( () => {
  43. view.destroy();
  44. view.destroy();
  45. } ).to.not.throw();
  46. } );
  47. } );
  48. } );