classiceditorui.js 2.7 KB

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