inlineeditoruiview.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import InlineEditorUIView from '../src/inlineeditoruiview';
  6. import FloatingToolbarView from '@ckeditor/ckeditor5-ui/src/toolbar/floating/floatingtoolbarview';
  7. import InlineEditableUIView from '@ckeditor/ckeditor5-ui/src/editableui/inline/inlineeditableuiview';
  8. import Locale from '@ckeditor/ckeditor5-utils/src/locale';
  9. describe( 'InlineEditorUIView', () => {
  10. let locale, view;
  11. beforeEach( () => {
  12. locale = new Locale( 'en' );
  13. view = new InlineEditorUIView( locale );
  14. } );
  15. describe( 'constructor()', () => {
  16. describe( '#toolbar', () => {
  17. it( 'is created', () => {
  18. expect( view.toolbar ).to.be.instanceof( FloatingToolbarView );
  19. } );
  20. it( 'is given a locate object', () => {
  21. expect( view.toolbar.locale ).to.equal( locale );
  22. } );
  23. it( 'is put into the "top" collection', () => {
  24. expect( view.body.get( 0 ) ).to.equal( view.toolbar );
  25. } );
  26. } );
  27. describe( '#editable', () => {
  28. it( 'is created', () => {
  29. expect( view.editable ).to.be.instanceof( InlineEditableUIView );
  30. } );
  31. it( 'is given a locate object', () => {
  32. expect( view.editable.locale ).to.equal( locale );
  33. } );
  34. it( 'is registered as a child', () => {
  35. const spy = sinon.spy( view.editable, 'destroy' );
  36. return view.init()
  37. .then( () => view.destroy() )
  38. .then( () => {
  39. sinon.assert.calledOnce( spy );
  40. } );
  41. } );
  42. } );
  43. } );
  44. describe( 'editableElement', () => {
  45. it( 'returns editable\'s view element', () => {
  46. return view.init()
  47. .then( () => {
  48. expect( view.editableElement.getAttribute( 'contentEditable' ) ).to.equal( 'true' );
  49. } )
  50. .then( () => view.destroy() );
  51. } );
  52. } );
  53. } );