inlineeditableuiview.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * @license Copyright (c) 2003-2017, 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. return ( view = new InlineEditableUIView( locale ) ).init();
  14. } );
  15. describe( 'constructor()', () => {
  16. it( 'accepts locale', () => {
  17. expect( view.locale ).to.equal( locale );
  18. } );
  19. it( 'sets initial values of attributes', () => {
  20. expect( view.name ).to.be.null;
  21. } );
  22. it( 'accepts editableElement', () => {
  23. view = new InlineEditableUIView( locale, editableElement );
  24. expect( view.element ).to.equal( editableElement );
  25. } );
  26. it( 'creates view#element from template when no editableElement provided', () => {
  27. expect( view.template ).to.be.an( 'object' );
  28. } );
  29. } );
  30. describe( 'editableElement', () => {
  31. const ariaLabel = 'Rich Text Editor, foo';
  32. beforeEach( () => {
  33. view.name = 'foo';
  34. } );
  35. it( 'has proper accessibility role', () => {
  36. expect( view.element.attributes.getNamedItem( 'role' ).value ).to.equal( 'textbox' );
  37. } );
  38. it( 'has proper ARIA label', () => {
  39. expect( view.element.getAttribute( 'aria-label' ) ).to.equal( ariaLabel );
  40. } );
  41. it( 'has proper class name', () => {
  42. expect( view.element.classList.contains( 'ck-editor__editable' ) ).to.be.true;
  43. expect( view.element.classList.contains( 'ck-editor__editable_inline' ) ).to.be.true;
  44. } );
  45. } );
  46. } );