boxededitoruiview.js 2.5 KB

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