classiceditoruiview.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 StickyPanelView from '@ckeditor/ckeditor5-ui/src/panel/sticky/stickypanelview';
  8. import ToolbarView from '@ckeditor/ckeditor5-ui/src/toolbar/toolbarview';
  9. import InlineEditableUIView from '@ckeditor/ckeditor5-ui/src/editableui/inline/inlineeditableuiview';
  10. import Locale from '@ckeditor/ckeditor5-utils/src/locale';
  11. describe( 'ClassicEditorUIView', () => {
  12. let locale, view;
  13. beforeEach( () => {
  14. locale = new Locale( 'en' );
  15. view = new ClassicEditorUIView( locale );
  16. } );
  17. describe( 'constructor()', () => {
  18. describe( '#stickyPanel', () => {
  19. it( 'is created', () => {
  20. expect( view.stickyPanel ).to.be.instanceof( StickyPanelView );
  21. } );
  22. it( 'is given a locate object', () => {
  23. expect( view.stickyPanel.locale ).to.equal( locale );
  24. } );
  25. it( 'is put into the "top" collection', () => {
  26. expect( view.top.get( 0 ) ).to.equal( view.stickyPanel );
  27. } );
  28. } );
  29. describe( '#toolbar', () => {
  30. it( 'is created', () => {
  31. expect( view.toolbar ).to.be.instanceof( ToolbarView );
  32. } );
  33. it( 'is given the right CSS class', () => {
  34. expect( view.toolbar.element.classList.contains( 'ck-editor-toolbar' ) ).to.be.true;
  35. } );
  36. it( 'is given a locate object', () => {
  37. expect( view.toolbar.locale ).to.equal( locale );
  38. } );
  39. it( 'is put into the "stickyPanel.content" collection', () => {
  40. expect( view.stickyPanel.content.get( 0 ) ).to.equal( view.toolbar );
  41. } );
  42. } );
  43. describe( '#editable', () => {
  44. it( 'is created', () => {
  45. expect( view.editable ).to.be.instanceof( InlineEditableUIView );
  46. } );
  47. it( 'is given a locate object', () => {
  48. expect( view.editable.locale ).to.equal( locale );
  49. } );
  50. it( 'is put into the "main" collection', () => {
  51. expect( view.main.get( 0 ) ).to.equal( view.editable );
  52. } );
  53. } );
  54. } );
  55. describe( 'editableElement', () => {
  56. it( 'returns editable\'s view element', () => {
  57. document.body.appendChild( view.element );
  58. view.stickyPanel.limiterElement = view.element;
  59. view.init();
  60. expect( view.editableElement.getAttribute( 'contentEditable' ) ).to.equal( 'true' );
  61. view.destroy();
  62. } );
  63. } );
  64. } );