inlineeditableuiview.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals document */
  6. import InlineEditableUIView from '../../../src/editableui/inline/inlineeditableuiview';
  7. import Locale from '@ckeditor/ckeditor5-utils/src/locale';
  8. describe( 'InlineEditableUIView', () => {
  9. let view, editableElement, locale;
  10. beforeEach( () => {
  11. locale = new Locale( 'en' );
  12. editableElement = document.createElement( 'div' );
  13. view = new InlineEditableUIView( locale );
  14. view.render();
  15. } );
  16. describe( 'constructor()', () => {
  17. it( 'accepts locale', () => {
  18. expect( view.locale ).to.equal( locale );
  19. } );
  20. it( 'sets initial values of attributes', () => {
  21. expect( view.name ).to.be.null;
  22. } );
  23. it( 'accepts editableElement', () => {
  24. view = new InlineEditableUIView( locale, editableElement );
  25. expect( view.editableElement ).to.equal( editableElement );
  26. } );
  27. it( 'creates view#element from template when no editableElement provided', () => {
  28. expect( view.template ).to.be.an( 'object' );
  29. } );
  30. } );
  31. describe( 'editableElement', () => {
  32. const ariaLabel = 'Rich Text Editor, foo';
  33. beforeEach( () => {
  34. view.name = 'foo';
  35. } );
  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( view.element.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. } );