classiceditoruiview.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals document */
  6. import ClassicEditorUIView from '../src/classiceditoruiview';
  7. import StickyToolbarView from '@ckeditor/ckeditor5-ui/src/toolbar/sticky/stickytoolbarview';
  8. import InlineEditableUIView from '@ckeditor/ckeditor5-ui/src/editableui/inline/inlineeditableuiview';
  9. import Locale from '@ckeditor/ckeditor5-utils/src/locale';
  10. describe( 'ClassicEditorUIView', () => {
  11. let locale, view;
  12. beforeEach( () => {
  13. locale = new Locale( 'en' );
  14. view = new ClassicEditorUIView( locale );
  15. } );
  16. describe( 'constructor()', () => {
  17. describe( '#toolbar', () => {
  18. it( 'is created', () => {
  19. expect( view.toolbar ).to.be.instanceof( StickyToolbarView );
  20. } );
  21. it( 'is given the right CSS class', () => {
  22. expect( view.toolbar.element.classList.contains( 'ck-editor-toolbar' ) ).to.be.true;
  23. } );
  24. it( 'is given a locate object', () => {
  25. expect( view.toolbar.locale ).to.equal( locale );
  26. } );
  27. it( 'is put into the "top" collection', () => {
  28. expect( view.top.get( 0 ) ).to.equal( view.toolbar );
  29. } );
  30. } );
  31. describe( '#editable', () => {
  32. it( 'is created', () => {
  33. expect( view.editable ).to.be.instanceof( InlineEditableUIView );
  34. } );
  35. it( 'is given a locate object', () => {
  36. expect( view.editable.locale ).to.equal( locale );
  37. } );
  38. it( 'is put into the "main" collection', () => {
  39. expect( view.main.get( 0 ) ).to.equal( view.editable );
  40. } );
  41. } );
  42. } );
  43. describe( 'editableElement', () => {
  44. it( 'returns editable\'s view element', () => {
  45. document.body.appendChild( view.element );
  46. view.toolbar.limiterElement = view.element;
  47. view.init();
  48. expect( view.editableElement.getAttribute( 'contentEditable' ) ).to.equal( 'true' );
  49. view.destroy();
  50. } );
  51. } );
  52. } );