blockquoteui.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* global document */
  6. import BlockQuoteEditing from '../src/blockquoteediting';
  7. import BlockQuoteUI from '../src/blockquoteui';
  8. import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
  9. describe( 'BlockQuoteUI', () => {
  10. let editor, command, element;
  11. beforeEach( () => {
  12. element = document.createElement( 'div' );
  13. document.body.appendChild( element );
  14. return ClassicTestEditor
  15. .create( element, {
  16. plugins: [ BlockQuoteEditing, BlockQuoteUI ]
  17. } )
  18. .then( newEditor => {
  19. editor = newEditor;
  20. command = editor.commands.get( 'blockQuote' );
  21. } );
  22. } );
  23. afterEach( () => {
  24. element.remove();
  25. return editor.destroy();
  26. } );
  27. describe( 'blockQuote button', () => {
  28. it( 'has the base properties', () => {
  29. const button = editor.ui.componentFactory.create( 'blockQuote' );
  30. expect( button ).to.have.property( 'label', 'Block quote' );
  31. expect( button ).to.have.property( 'icon' );
  32. expect( button ).to.have.property( 'tooltip', true );
  33. } );
  34. it( 'has isOn bound to command\'s value', () => {
  35. const button = editor.ui.componentFactory.create( 'blockQuote' );
  36. command.value = false;
  37. expect( button ).to.have.property( 'isOn', false );
  38. command.value = true;
  39. expect( button ).to.have.property( 'isOn', true );
  40. } );
  41. it( 'has isEnabled bound to command\'s isEnabled', () => {
  42. const button = editor.ui.componentFactory.create( 'blockQuote' );
  43. command.isEnabled = true;
  44. expect( button ).to.have.property( 'isEnabled', true );
  45. command.isEnabled = false;
  46. expect( button ).to.have.property( 'isEnabled', false );
  47. } );
  48. it( 'executes command when it\'s executed', () => {
  49. const button = editor.ui.componentFactory.create( 'blockQuote' );
  50. const spy = sinon.stub( editor, 'execute' );
  51. button.fire( 'execute' );
  52. expect( spy.calledOnce ).to.be.true;
  53. expect( spy.args[ 0 ][ 0 ] ).to.equal( 'blockQuote' );
  54. } );
  55. } );
  56. } );