8
0

classiceditorui.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* bender-tags: editor, browser-only */
  6. import ClassicEditorUI from '/ckeditor5/editor-classic/classiceditorui.js';
  7. import BoxedEditorUIView from '/ckeditor5/ui/editorui/boxed/boxededitoruiview.js';
  8. import Model from '/ckeditor5/ui/model.js';
  9. import Button from '/ckeditor5/ui/button/button.js';
  10. import ButtonView from '/ckeditor5/ui/button/buttonview.js';
  11. import Toolbar from '/ckeditor5/ui/toolbar/toolbar.js';
  12. import StickyToolbarView from '/ckeditor5/ui/toolbar/sticky/stickytoolbarview.js';
  13. import EditableUI from '/ckeditor5/ui/editableui/editableui.js';
  14. import InlineEditableUIView from '/ckeditor5/ui/editableui/inline/inlineeditableuiview.js';
  15. import ClassicTestEditor from '/tests/core/_utils/classictesteditor.js';
  16. describe( 'ClassicEditorUI', () => {
  17. let editorElement, editor, editorUI;
  18. beforeEach( () => {
  19. editorElement = document.createElement( 'div' );
  20. document.body.appendChild( editorElement );
  21. editor = new ClassicTestEditor( editorElement, {
  22. toolbar: [ 'foo', 'bar' ]
  23. } );
  24. editor.ui = editorUI = new ClassicEditorUI( editor );
  25. editorUI.view = new BoxedEditorUIView( editor.locale );
  26. editorUI.featureComponents.add( 'foo', Button, ButtonView, new Model( {} ) );
  27. editorUI.featureComponents.add( 'bar', Button, ButtonView, new Model( {} ) );
  28. } );
  29. describe( 'constructor', () => {
  30. it( 'creates toolbar', () => {
  31. expect( editorUI.toolbar ).to.be.instanceof( Toolbar );
  32. expect( editorUI.toolbar.view ).to.be.instanceof( StickyToolbarView );
  33. } );
  34. it( 'creates editable', () => {
  35. expect( editorUI.editable ).to.be.instanceof( EditableUI );
  36. expect( editorUI.editable.view ).to.be.instanceof( InlineEditableUIView );
  37. } );
  38. } );
  39. describe( 'editableElement', () => {
  40. it( 'returns editable\'s view element', () => {
  41. document.body.appendChild( editorUI.view.element );
  42. return editorUI.init()
  43. .then( () => {
  44. expect( editorUI.editableElement.getAttribute( 'contentEditable' ) ).to.equal( 'true' );
  45. } );
  46. } );
  47. } );
  48. describe( 'init', () => {
  49. it( 'returns a promise', () => {
  50. document.body.appendChild( editorUI.view.element );
  51. expect( editorUI.init() ).to.be.instanceof( Promise );
  52. } );
  53. } );
  54. describe( '_createToolbar', () => {
  55. it( 'passes toolbar config to the model', () => {
  56. expect( editorUI.toolbar.model.config ).to.have.members( [ 'foo', 'bar' ] );
  57. } );
  58. } );
  59. } );