8
0

switchbuttonview.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  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. } );
  22. describe( 'render', () => {
  23. it( 'adds #toggleSwitchView to #children', () => {
  24. expect( view.children.get( 2 ) ).to.equal( view.toggleSwitchView );
  25. } );
  26. } );
  27. describe( '#toggleSwitchView', () => {
  28. it( 'has proper DOM structure', () => {
  29. const toggleElement = view.toggleSwitchView.element;
  30. expect( toggleElement.classList.contains( 'ck' ) ).to.be.true;
  31. expect( toggleElement.classList.contains( 'ck-button__toggle' ) ).to.be.true;
  32. expect( toggleElement.firstChild.classList.contains( 'ck' ) ).to.be.true;
  33. expect( toggleElement.firstChild.classList.contains( 'ck-button__toggle__inner' ) ).to.be.true;
  34. } );
  35. } );
  36. } );