blockquote.js 2.1 KB

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