editoruiview.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  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. testUtils.createSinonSandbox();
  11. describe( 'EditorUIView', () => {
  12. let view, locale;
  13. beforeEach( () => {
  14. locale = new Locale( 'en' );
  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( 'sets the right class set to the body region', () => {
  31. const el = view._bodyCollectionContainer;
  32. expect( el.parentNode ).to.equal( document.body );
  33. expect( el.classList.contains( 'ck-body' ) ).to.be.true;
  34. expect( el.classList.contains( 'ck-rounded-corners' ) ).to.be.true;
  35. expect( el.classList.contains( 'ck-reset_all' ) ).to.be.true;
  36. } );
  37. } );
  38. describe( 'destroy()', () => {
  39. it( 'removes the body region container', () => {
  40. const el = view._bodyCollectionContainer;
  41. view.destroy();
  42. expect( el.parentNode ).to.be.null;
  43. } );
  44. it( 'can be called multiple times', () => {
  45. expect( () => {
  46. view.destroy();
  47. view.destroy();
  48. } ).to.not.throw();
  49. } );
  50. } );
  51. } );