dropdownbuttonview.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
  6. import IconView from '../../../src/icon/iconview';
  7. import DropdownButtonView from '../../../src/dropdown/button/dropdownbuttonview';
  8. describe( 'DropdownButtonView', () => {
  9. let locale, view;
  10. testUtils.createSinonSandbox();
  11. beforeEach( () => {
  12. locale = { t() {} };
  13. view = new DropdownButtonView( locale );
  14. view.render();
  15. } );
  16. describe( 'constructor()', () => {
  17. it( 'sets view#locale', () => {
  18. expect( view.locale ).to.equal( locale );
  19. } );
  20. it( 'creates view#arrowView', () => {
  21. expect( view.arrowView ).to.be.instanceOf( IconView );
  22. } );
  23. it( 'creates element from template', () => {
  24. expect( view.element.tagName ).to.equal( 'BUTTON' );
  25. expect( view.element.attributes[ 'aria-haspopup' ].value ).to.equal( 'true' );
  26. } );
  27. } );
  28. describe( 'bindings', () => {
  29. it( 'delegates view#execute to view#open', () => {
  30. const spy = sinon.spy();
  31. view.on( 'open', spy );
  32. view.fire( 'execute' );
  33. sinon.assert.calledOnce( spy );
  34. } );
  35. } );
  36. } );