8
0

classiceditorui.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 Toolbar from '/ckeditor5/ui/toolbar/toolbar.js';
  9. import StickyToolbarView from '/ckeditor5/ui/toolbar/sticky/stickytoolbarview.js';
  10. import EditableUI from '/ckeditor5/ui/editableui/editableui.js';
  11. import InlineEditableUIView from '/ckeditor5/ui/editableui/inline/inlineeditableuiview.js';
  12. import ClassicTestEditor from '/tests/core/_utils/classictesteditor.js';
  13. describe( 'ClassicEditorUI', () => {
  14. let editorElement, editor, editorUI;
  15. beforeEach( () => {
  16. editorElement = document.createElement( 'div' );
  17. document.body.appendChild( editorElement );
  18. editor = new ClassicTestEditor( editorElement );
  19. editorUI = new ClassicEditorUI( editor );
  20. editorUI.view = new BoxedEditorUIView( editor.locale );
  21. } );
  22. describe( 'constructor', () => {
  23. it( 'creates toolbar', () => {
  24. expect( editorUI.toolbar ).to.be.instanceof( Toolbar );
  25. expect( editorUI.toolbar.view ).to.be.instanceof( StickyToolbarView );
  26. } );
  27. it( 'creates editable', () => {
  28. expect( editorUI.editable ).to.be.instanceof( EditableUI );
  29. expect( editorUI.editable.view ).to.be.instanceof( InlineEditableUIView );
  30. } );
  31. } );
  32. describe( 'editableElement', () => {
  33. it( 'returns editable\'s view element', () => {
  34. document.body.appendChild( editorUI.view.element );
  35. return editorUI.init()
  36. .then( () => {
  37. expect( editorUI.editableElement.getAttribute( 'contentEditable' ) ).to.equal( 'true' );
  38. } );
  39. } );
  40. } );
  41. describe( 'init', () => {
  42. it( 'adds buttons', () => {
  43. editor.config.set( 'toolbar', [ 'foo', 'bar' ] );
  44. document.body.appendChild( editorUI.view.element );
  45. const spy = sinon.stub( editorUI.toolbar, 'addButtons' );
  46. return editorUI.init()
  47. .then( () => {
  48. expect( spy.calledOnce ).to.be.true;
  49. expect( spy.args[ 0 ][ 0 ] ).to.deep.equal( [ 'foo', 'bar' ] );
  50. } );
  51. } );
  52. it( 'returns a promise', () => {
  53. document.body.appendChild( editorUI.view.element );
  54. expect( editorUI.init() ).to.be.instanceof( Promise );
  55. } );
  56. } );
  57. } );