classiceditoruiview.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. 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 the right CSS class', () => {
  38. expect( view.toolbar.element.classList.contains( 'ck-editor-toolbar' ) ).to.be.true;
  39. } );
  40. it( 'is given a locate object', () => {
  41. expect( view.toolbar.locale ).to.equal( locale );
  42. } );
  43. it( 'is put into the "stickyPanel.content" collection', () => {
  44. expect( view.stickyPanel.content.get( 0 ) ).to.equal( view.toolbar );
  45. } );
  46. } );
  47. describe( '#editable', () => {
  48. it( 'is created', () => {
  49. expect( view.editable ).to.be.instanceof( InlineEditableUIView );
  50. } );
  51. it( 'is given a locate object', () => {
  52. expect( view.editable.locale ).to.equal( locale );
  53. } );
  54. it( 'is put into the "main" collection', () => {
  55. expect( view.main.get( 0 ) ).to.equal( view.editable );
  56. } );
  57. } );
  58. } );
  59. describe( 'editableElement', () => {
  60. it( 'returns editable\'s view element', () => {
  61. document.body.appendChild( view.element );
  62. view.stickyPanel.limiterElement = view.element;
  63. expect( view.editableElement.getAttribute( 'contentEditable' ) ).to.equal( 'true' );
  64. view.element.remove();
  65. view.destroy();
  66. } );
  67. } );
  68. } );