listitemview.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import ButtonView from '../../src/button/buttonview';
  6. import ListItemView from '../../src/list/listitemview';
  7. import ViewCollection from '../../src/viewcollection';
  8. describe( 'ListItemView', () => {
  9. let view;
  10. beforeEach( () => {
  11. view = new ListItemView();
  12. return view.render();
  13. } );
  14. describe( 'constructor()', () => {
  15. it( 'creates element from template', () => {
  16. expect( view.element.classList.contains( 'ck' ) ).to.be.true;
  17. expect( view.element.classList.contains( 'ck-list__item' ) ).to.be.true;
  18. } );
  19. it( 'creates view#children collection', () => {
  20. expect( view.children ).to.be.instanceOf( ViewCollection );
  21. } );
  22. } );
  23. describe( 'focus()', () => {
  24. it( 'focuses the first child item', () => {
  25. const button = new ButtonView();
  26. view.children.add( button );
  27. const spy = sinon.spy( button.element, 'focus' );
  28. view.focus();
  29. sinon.assert.calledOnce( spy );
  30. } );
  31. } );
  32. } );