classiceditoruiview.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import ClassicEditorUIView from '../src/classiceditoruiview';
  6. import EditingView from '@ckeditor/ckeditor5-engine/src/view/view';
  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. import createRoot from '@ckeditor/ckeditor5-engine/tests/view/_utils/createroot.js';
  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();
  18. editingView = new EditingView();
  19. editingViewRoot = createRoot( editingView.document );
  20. view = new ClassicEditorUIView( locale, editingView );
  21. view.editable.name = editingViewRoot.rootName;
  22. view.render();
  23. } );
  24. afterEach( () => {
  25. view.destroy();
  26. } );
  27. describe( 'constructor()', () => {
  28. describe( '#stickyPanel', () => {
  29. it( 'is created', () => {
  30. expect( view.stickyPanel ).to.be.instanceof( StickyPanelView );
  31. } );
  32. it( 'is given a locate object', () => {
  33. expect( view.stickyPanel.locale ).to.equal( locale );
  34. } );
  35. it( 'is put into the "top" collection', () => {
  36. expect( view.top.get( 0 ) ).to.equal( view.stickyPanel );
  37. } );
  38. } );
  39. describe( '#toolbar', () => {
  40. it( 'is created', () => {
  41. expect( view.toolbar ).to.be.instanceof( ToolbarView );
  42. } );
  43. it( 'is given a locate object', () => {
  44. expect( view.toolbar.locale ).to.equal( locale );
  45. } );
  46. it( 'is put into the "stickyPanel.content" collection', () => {
  47. expect( view.stickyPanel.content.get( 0 ) ).to.equal( view.toolbar );
  48. } );
  49. } );
  50. describe( '#editable', () => {
  51. it( 'is created', () => {
  52. expect( view.editable ).to.be.instanceof( InlineEditableUIView );
  53. } );
  54. it( 'is given a locate object', () => {
  55. expect( view.editable.locale ).to.equal( locale );
  56. } );
  57. it( 'is put into the "main" collection', () => {
  58. expect( view.main.get( 0 ) ).to.equal( view.editable );
  59. } );
  60. } );
  61. } );
  62. } );