8
0

boxededitoruiview.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * @license Copyright (c) 2003-2018, 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' ) ).to.be.true;
  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( /^ck-editor__aria-label_\w+$/ );
  31. } );
  32. it( 'bootstraps the voice label from template', () => {
  33. const voiceLabel = view.element.firstChild;
  34. expect( voiceLabel.classList.contains( 'ck-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. } );