8
0

classiceditoruiview.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * @license Copyright (c) 2003-2018, 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. view.render();
  17. } );
  18. afterEach( () => {
  19. view.destroy();
  20. } );
  21. describe( 'constructor()', () => {
  22. describe( '#stickyPanel', () => {
  23. it( 'is created', () => {
  24. expect( view.stickyPanel ).to.be.instanceof( StickyPanelView );
  25. } );
  26. it( 'is given a locate object', () => {
  27. expect( view.stickyPanel.locale ).to.equal( locale );
  28. } );
  29. it( 'is put into the "top" collection', () => {
  30. expect( view.top.get( 0 ) ).to.equal( view.stickyPanel );
  31. } );
  32. } );
  33. describe( '#toolbar', () => {
  34. it( 'is created', () => {
  35. expect( view.toolbar ).to.be.instanceof( ToolbarView );
  36. } );
  37. it( 'is given a locate object', () => {
  38. expect( view.toolbar.locale ).to.equal( locale );
  39. } );
  40. it( 'is put into the "stickyPanel.content" collection', () => {
  41. expect( view.stickyPanel.content.get( 0 ) ).to.equal( view.toolbar );
  42. } );
  43. } );
  44. describe( '#editable', () => {
  45. it( 'is created', () => {
  46. expect( view.editable ).to.be.instanceof( InlineEditableUIView );
  47. } );
  48. it( 'is given a locate object', () => {
  49. expect( view.editable.locale ).to.equal( locale );
  50. } );
  51. it( 'is put into the "main" collection', () => {
  52. expect( view.main.get( 0 ) ).to.equal( view.editable );
  53. } );
  54. } );
  55. } );
  56. describe( 'editableElement', () => {
  57. it( 'returns editable\'s view element', () => {
  58. document.body.appendChild( view.element );
  59. view.stickyPanel.limiterElement = view.element;
  60. expect( view.editableElement.getAttribute( 'contentEditable' ) ).to.equal( 'true' );
  61. view.element.remove();
  62. view.destroy();
  63. } );
  64. } );
  65. } );