editoruiview.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * @license Copyright (c) 2003-2018, 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. describe( 'EditorUIView', () => {
  11. let view, locale;
  12. testUtils.createSinonSandbox();
  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' ) ).to.be.true;
  34. expect( el.classList.contains( 'ck-body' ) ).to.be.true;
  35. expect( el.classList.contains( 'ck-rounded-corners' ) ).to.be.true;
  36. expect( el.classList.contains( 'ck-reset_all' ) ).to.be.true;
  37. } );
  38. } );
  39. describe( 'destroy()', () => {
  40. it( 'removes the body region container', () => {
  41. const el = view._bodyCollectionContainer;
  42. view.destroy();
  43. expect( el.parentNode ).to.be.null;
  44. } );
  45. it( 'can be called multiple times', () => {
  46. expect( () => {
  47. view.destroy();
  48. view.destroy();
  49. } ).to.not.throw();
  50. } );
  51. } );
  52. } );