classiceditoruiview.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. it( 'has automatic items grouping enabled', () => {
  50. expect( view.toolbar.options.shouldGroupWhenFull ).to.be.true;
  51. } );
  52. } );
  53. describe( '#editable', () => {
  54. it( 'is created', () => {
  55. expect( view.editable ).to.be.instanceof( InlineEditableUIView );
  56. } );
  57. it( 'is given a locate object', () => {
  58. expect( view.editable.locale ).to.equal( locale );
  59. } );
  60. it( 'is put into the "main" collection', () => {
  61. expect( view.main.get( 0 ) ).to.equal( view.editable );
  62. } );
  63. } );
  64. } );
  65. } );