8
0

classiceditoruiview.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * @license Copyright (c) 2003-2020, 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. describe( 'automatic items grouping', () => {
  50. it( 'should be disabled by default', () => {
  51. expect( view.toolbar.options.shouldGroupWhenFull ).to.be.undefined;
  52. } );
  53. it( 'should be controlled via options.shouldToolbarGroupWhenFull', () => {
  54. const locale = new Locale();
  55. const editingView = new EditingView();
  56. const editingViewRoot = createRoot( editingView.document );
  57. const view = new ClassicEditorUIView( locale, editingView, {
  58. shouldToolbarGroupWhenFull: true
  59. } );
  60. view.editable.name = editingViewRoot.rootName;
  61. view.render();
  62. expect( view.toolbar.options.shouldGroupWhenFull ).to.be.true;
  63. return view.destroy();
  64. } );
  65. } );
  66. } );
  67. describe( '#editable', () => {
  68. it( 'is created', () => {
  69. expect( view.editable ).to.be.instanceof( InlineEditableUIView );
  70. } );
  71. it( 'is given a locate object', () => {
  72. expect( view.editable.locale ).to.equal( locale );
  73. } );
  74. it( 'is put into the "main" collection', () => {
  75. expect( view.main.get( 0 ) ).to.equal( view.editable );
  76. } );
  77. } );
  78. } );
  79. } );