boxededitoruiview.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. view.render();
  13. element = view.element;
  14. } );
  15. afterEach( () => {
  16. view.destroy();
  17. } );
  18. describe( 'constructor()', () => {
  19. it( 'adds view collections', () => {
  20. expect( view.top ).to.be.instanceof( ViewCollection );
  21. expect( view.main ).to.be.instanceof( ViewCollection );
  22. } );
  23. it( 'bootstraps the view element from template', () => {
  24. expect( view.element.classList.contains( 'ck-editor' ) ).to.be.true;
  25. expect( view.element.classList.contains( 'ck-reset' ) ).to.be.true;
  26. expect( view.element.classList.contains( 'ck-rounded-corners' ) ).to.be.true;
  27. expect( element.attributes[ 'aria-labelledby' ].value )
  28. .to.equal( view.element.firstChild.id )
  29. .to.match( /^cke-editor__aria-label_\w+$/ );
  30. } );
  31. it( 'bootstraps the voice label from template', () => {
  32. const voiceLabel = view.element.firstChild;
  33. expect( voiceLabel.classList.contains( 'cke-voice-label' ) ).to.be.true;
  34. expect( voiceLabel.textContent ).to.equal( 'Rich Text Editor' );
  35. } );
  36. it( 'setups accessibility of the view element', () => {
  37. expect( element.attributes.getNamedItem( 'aria-labelledby' ).value ).to.equal(
  38. view.element.firstChild.id );
  39. expect( element.attributes.getNamedItem( 'role' ).value ).to.equal( 'application' );
  40. expect( element.attributes.getNamedItem( 'lang' ).value ).to.equal( 'en' );
  41. } );
  42. it( 'bootstraps the view region elements from template', () => {
  43. expect( element.childNodes[ 1 ].classList.contains( 'ck-editor__top' ) ).to.be.true;
  44. expect( element.childNodes[ 2 ].classList.contains( 'ck-editor__main' ) ).to.be.true;
  45. } );
  46. it( 'setups accessibility of the view region elements', () => {
  47. expect( element.childNodes[ 1 ].attributes.getNamedItem( 'role' ).value ).to.equal( 'presentation' );
  48. expect( element.childNodes[ 2 ].attributes.getNamedItem( 'role' ).value ).to.equal( 'presentation' );
  49. } );
  50. } );
  51. } );