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. return view.init();
  17. } );
  18. describe( 'constructor()', () => {
  19. it( 'accepts locale', () => {
  20. expect( view.locale ).to.equal( locale );
  21. } );
  22. it( 'sets all the properties', () => {
  23. expect( view.body ).to.be.instanceof( ViewCollection );
  24. } );
  25. } );
  26. describe( 'init()', () => {
  27. it( 'sets the right class set to the body region', () => {
  28. const el = view._bodyCollectionContainer;
  29. expect( el.parentNode ).to.equal( document.body );
  30. expect( el.classList.contains( 'ck-body' ) ).to.be.true;
  31. expect( el.classList.contains( 'ck-rounded-corners' ) ).to.be.true;
  32. expect( el.classList.contains( 'ck-reset_all' ) ).to.be.true;
  33. } );
  34. } );
  35. describe( 'destroy()', () => {
  36. it( 'removes the body region container', () => {
  37. const el = view._bodyCollectionContainer;
  38. return view.destroy().then( () => {
  39. expect( el.parentNode ).to.be.null;
  40. } );
  41. } );
  42. it( 'can be called multiple times', done => {
  43. expect( () => {
  44. view.destroy().then( () => {
  45. return view.destroy().then( () => {
  46. done();
  47. } );
  48. } );
  49. } ).to.not.throw();
  50. } );
  51. } );
  52. } );