classiceditoruiview.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import ClassicEditorUIView from '../src/classiceditoruiview';
  6. import EditingView from '@ckeditor/ckeditor5-engine/src/view/view';
  7. import ViewRootEditableElement from '@ckeditor/ckeditor5-engine/src/view/rooteditableelement';
  8. import StickyPanelView from '@ckeditor/ckeditor5-ui/src/panel/sticky/stickypanelview';
  9. import ToolbarView from '@ckeditor/ckeditor5-ui/src/toolbar/toolbarview';
  10. import InlineEditableUIView from '@ckeditor/ckeditor5-ui/src/editableui/inline/inlineeditableuiview';
  11. import Locale from '@ckeditor/ckeditor5-utils/src/locale';
  12. import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
  13. describe( 'ClassicEditorUIView', () => {
  14. let locale, view, editingView, editingViewRoot;
  15. testUtils.createSinonSandbox();
  16. beforeEach( () => {
  17. locale = new Locale( 'en' );
  18. setUpEditingView();
  19. view = new ClassicEditorUIView( locale, editingView );
  20. view.editable.name = editingViewRoot.rootName;
  21. view.render();
  22. } );
  23. afterEach( () => {
  24. view.destroy();
  25. } );
  26. describe( 'constructor()', () => {
  27. describe( '#stickyPanel', () => {
  28. it( 'is created', () => {
  29. expect( view.stickyPanel ).to.be.instanceof( StickyPanelView );
  30. } );
  31. it( 'is given a locate object', () => {
  32. expect( view.stickyPanel.locale ).to.equal( locale );
  33. } );
  34. it( 'is put into the "top" collection', () => {
  35. expect( view.top.get( 0 ) ).to.equal( view.stickyPanel );
  36. } );
  37. } );
  38. describe( '#toolbar', () => {
  39. it( 'is created', () => {
  40. expect( view.toolbar ).to.be.instanceof( ToolbarView );
  41. } );
  42. it( 'is given a locate object', () => {
  43. expect( view.toolbar.locale ).to.equal( locale );
  44. } );
  45. it( 'is put into the "stickyPanel.content" collection', () => {
  46. expect( view.stickyPanel.content.get( 0 ) ).to.equal( view.toolbar );
  47. } );
  48. } );
  49. describe( '#editable', () => {
  50. it( 'is created', () => {
  51. expect( view.editable ).to.be.instanceof( InlineEditableUIView );
  52. } );
  53. it( 'is given a locate object', () => {
  54. expect( view.editable.locale ).to.equal( locale );
  55. } );
  56. it( 'is put into the "main" collection', () => {
  57. expect( view.main.get( 0 ) ).to.equal( view.editable );
  58. } );
  59. } );
  60. } );
  61. function setUpEditingView() {
  62. editingView = new EditingView();
  63. editingViewRoot = new ViewRootEditableElement( 'div' );
  64. editingViewRoot._document = editingView.document;
  65. editingView.document.roots.add( editingViewRoot );
  66. }
  67. } );