8
0

boxededitoruiview.js 2.3 KB

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