8
0

switchbuttonview.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 SwitchButtonView from '../../src/button/switchbuttonview';
  6. import View from '../../src/view';
  7. describe( 'SwitchButtonView', () => {
  8. let locale, view;
  9. beforeEach( () => {
  10. locale = { t() {} };
  11. view = new SwitchButtonView( locale );
  12. view.render();
  13. } );
  14. describe( 'constructor()', () => {
  15. it( 'creates #toggleSwitchView', () => {
  16. expect( view.toggleSwitchView ).to.be.instanceOf( View );
  17. } );
  18. it( 'sets CSS class', () => {
  19. expect( view.element.classList.contains( 'ck-switchbutton' ) ).to.be.true;
  20. } );
  21. it( 'sets isToggleable flag to true', () => {
  22. expect( view.isToggleable ).to.be.true;
  23. } );
  24. } );
  25. describe( 'render', () => {
  26. it( 'adds #toggleSwitchView to #children', () => {
  27. expect( view.children.get( 2 ) ).to.equal( view.toggleSwitchView );
  28. } );
  29. } );
  30. describe( '#toggleSwitchView', () => {
  31. it( 'has proper DOM structure', () => {
  32. const toggleElement = view.toggleSwitchView.element;
  33. expect( toggleElement.classList.contains( 'ck' ) ).to.be.true;
  34. expect( toggleElement.classList.contains( 'ck-button__toggle' ) ).to.be.true;
  35. expect( toggleElement.firstChild.classList.contains( 'ck' ) ).to.be.true;
  36. expect( toggleElement.firstChild.classList.contains( 'ck-button__toggle__inner' ) ).to.be.true;
  37. } );
  38. } );
  39. } );