8
0

inlineeditableuiview.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* bender-tags: editable */
  6. import EditableUI from '/ckeditor5/ui/editableui/editableui.js';
  7. import InlineEditableUIView from '/ckeditor5/ui/editableui/inline/inlineeditableuiview.js';
  8. import Model from '/ckeditor5/ui/model.js';
  9. import Locale from '/ckeditor5/utils/locale.js';
  10. describe( 'InlineEditableUIView', () => {
  11. let editable, view, editableElement, locale;
  12. beforeEach( () => {
  13. editable = new Model( {
  14. isReadOnly: false,
  15. isFocused: false,
  16. rootName: 'foo'
  17. } );
  18. locale = new Locale( 'en' );
  19. view = new InlineEditableUIView( locale );
  20. editableElement = document.createElement( 'div' );
  21. return new EditableUI( editable, view ).init();
  22. } );
  23. describe( 'constructor', () => {
  24. it( 'accepts locale', () => {
  25. expect( view.locale ).to.equal( locale );
  26. } );
  27. it( 'accepts editableElement', () => {
  28. view = new InlineEditableUIView( locale, editableElement );
  29. expect( view.element ).to.equal( editableElement );
  30. } );
  31. it( 'creates view#element from template when no editableElement provided', () => {
  32. expect( view.template ).to.be.an( 'object' );
  33. } );
  34. } );
  35. describe( 'editableElement', () => {
  36. const ariaLabel = 'Rich Text Editor, foo';
  37. it( 'has proper accessibility role', () => {
  38. expect( view.element.attributes.getNamedItem( 'role' ).value ).to.equal( 'textbox' );
  39. } );
  40. it( 'has proper ARIA label', () => {
  41. expect( view.element.getAttribute( 'aria-label' ) ).to.equal( ariaLabel );
  42. } );
  43. it( 'has proper title', () => {
  44. expect( view.element.getAttribute( 'title' ) ).to.equal( ariaLabel );
  45. } );
  46. it( 'has proper class name', () => {
  47. expect( view.element.classList.contains( 'ck-editor__editable' ) ).to.be.true;
  48. expect( view.element.classList.contains( 'ck-editor__editable_inline' ) ).to.be.true;
  49. } );
  50. } );
  51. } );