boxededitoruiview.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import BoxedEditorUIView from '../../../src/editorui/boxed/boxededitoruiview';
  6. import Locale from '@ckeditor/ckeditor5-utils/src/locale';
  7. import ViewCollection from '../../../src/viewcollection';
  8. describe( 'BoxedEditorUIView', () => {
  9. let view, element;
  10. beforeEach( () => {
  11. view = new BoxedEditorUIView( new Locale( 'en' ) );
  12. element = view.element;
  13. return view.init();
  14. } );
  15. describe( 'constructor()', () => {
  16. it( 'adds view collections', () => {
  17. expect( view.top ).to.be.instanceof( ViewCollection );
  18. expect( view.main ).to.be.instanceof( ViewCollection );
  19. } );
  20. it( 'sets "width" and "height" attributes', () => {
  21. expect( view.width ).to.equal( null );
  22. expect( view.height ).to.equal( null );
  23. } );
  24. it( 'bootstraps the view element from template', () => {
  25. expect( view.element.classList.contains( 'ck-editor' ) ).to.be.true;
  26. expect( view.element.classList.contains( 'ck-reset' ) ).to.be.true;
  27. expect( view.element.classList.contains( 'ck-rounded-corners' ) ).to.be.true;
  28. expect( element.attributes[ 'aria-labelledby' ].value )
  29. .to.equal( view.element.firstChild.id )
  30. .to.match( /^cke-editor__aria-label_\w+$/ );
  31. } );
  32. it( 'bootstraps the voice label from template', () => {
  33. const voiceLabel = view.element.firstChild;
  34. expect( voiceLabel.classList.contains( 'cke-voice-label' ) ).to.be.true;
  35. expect( voiceLabel.textContent ).to.equal( 'Rich Text Editor' );
  36. } );
  37. it( 'setups accessibility of the view element', () => {
  38. expect( element.attributes.getNamedItem( 'aria-labelledby' ).value ).to.equal(
  39. view.element.firstChild.id );
  40. expect( element.attributes.getNamedItem( 'role' ).value ).to.equal( 'application' );
  41. expect( element.attributes.getNamedItem( 'lang' ).value ).to.equal( 'en' );
  42. } );
  43. it( 'bootstraps the view region elements from template', () => {
  44. expect( element.childNodes[ 1 ].classList.contains( 'ck-editor__top' ) ).to.be.true;
  45. expect( element.childNodes[ 2 ].classList.contains( 'ck-editor__main' ) ).to.be.true;
  46. } );
  47. it( 'setups accessibility of the view region elements', () => {
  48. expect( element.childNodes[ 1 ].attributes.getNamedItem( 'role' ).value ).to.equal( 'presentation' );
  49. expect( element.childNodes[ 2 ].attributes.getNamedItem( 'role' ).value ).to.equal( 'presentation' );
  50. } );
  51. } );
  52. } );