inlineeditableuiview.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. /* globals document */
  6. import EditingView from '@ckeditor/ckeditor5-engine/src/view/view';
  7. import ViewRootEditableElement from '@ckeditor/ckeditor5-engine/src/view/rooteditableelement';
  8. import InlineEditableUIView from '../../../src/editableui/inline/inlineeditableuiview';
  9. import Locale from '@ckeditor/ckeditor5-utils/src/locale';
  10. describe( 'InlineEditableUIView', () => {
  11. let view, editableElement, editingView, editingViewRoot, locale;
  12. beforeEach( () => {
  13. locale = new Locale();
  14. editableElement = document.createElement( 'div' );
  15. editingView = new EditingView();
  16. editingViewRoot = new ViewRootEditableElement( editingView.document, 'div' );
  17. editingView.document.roots.add( editingViewRoot );
  18. view = new InlineEditableUIView( locale, editingView );
  19. view.name = editingViewRoot.rootName;
  20. view.render();
  21. } );
  22. describe( 'constructor()', () => {
  23. it( 'accepts locale', () => {
  24. expect( view.locale ).to.equal( locale );
  25. } );
  26. it( 'accepts editableElement', () => {
  27. view = new InlineEditableUIView( locale, editingView, editableElement );
  28. expect( view._editableElement ).to.equal( editableElement );
  29. } );
  30. it( 'creates view#element from template when no editableElement provided', () => {
  31. expect( view.template ).to.be.an( 'object' );
  32. } );
  33. } );
  34. describe( 'editableElement', () => {
  35. const ariaLabel = 'Rich Text Editor, main';
  36. it( 'has proper accessibility role', () => {
  37. expect( view.element.attributes.getNamedItem( 'role' ).value ).to.equal( 'textbox' );
  38. } );
  39. it( 'has proper ARIA label', () => {
  40. expect( editingViewRoot.getAttribute( 'aria-label' ) ).to.equal( ariaLabel );
  41. } );
  42. it( 'has proper class name', () => {
  43. expect( view.element.classList.contains( 'ck-editor__editable' ) ).to.be.true;
  44. expect( view.element.classList.contains( 'ck-editor__editable_inline' ) ).to.be.true;
  45. } );
  46. } );
  47. } );