inlineeditableuiview.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. 'use strict';
  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 model, view, editableElement, locale;
  12. beforeEach( () => {
  13. model = new Model( { isEditable: true, isFocused: false, name: 'foo' } );
  14. locale = new Locale( 'en' );
  15. view = new InlineEditableUIView( model, locale );
  16. editableElement = document.createElement( 'div' );
  17. return view.init();
  18. } );
  19. describe( 'constructor', () => {
  20. it( 'accepts model', () => {
  21. expect( view.model ).to.equal( model );
  22. } );
  23. it( 'accepts locale', () => {
  24. expect( view.locale ).to.equal( locale );
  25. } );
  26. it( 'accepts editableElement', () => {
  27. view = new InlineEditableUIView( model, locale, editableElement );
  28. expect( view.element ).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, foo';
  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 title', () => {
  43. expect( view.element.getAttribute( 'title' ) ).to.equal( ariaLabel );
  44. } );
  45. it( 'has proper class name', () => {
  46. expect( view.element.classList.contains( 'ck-editor__editable' ) ).to.be.true;
  47. expect( view.element.classList.contains( 'ck-editor__editable_inline' ) ).to.be.true;
  48. } );
  49. } );
  50. } );