8
0

blockquote.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 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
  15. .create( element, {
  16. plugins: [ BlockQuote ]
  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. it( 'requires BlockQuoteEngine', () => {
  28. expect( BlockQuote.requires ).to.deep.equal( [ BlockQuoteEngine ] );
  29. } );
  30. describe( 'blockQuote button', () => {
  31. it( 'has the base properties', () => {
  32. const button = editor.ui.componentFactory.create( 'blockQuote' );
  33. expect( button ).to.have.property( 'label', 'Block quote' );
  34. expect( button ).to.have.property( 'icon' );
  35. expect( button ).to.have.property( 'tooltip', true );
  36. } );
  37. it( 'has isOn bound to command\'s value', () => {
  38. const button = editor.ui.componentFactory.create( 'blockQuote' );
  39. command.value = false;
  40. expect( button ).to.have.property( 'isOn', false );
  41. command.value = true;
  42. expect( button ).to.have.property( 'isOn', true );
  43. } );
  44. it( 'has isEnabled bound to command\'s isEnabled', () => {
  45. const button = editor.ui.componentFactory.create( 'blockQuote' );
  46. command.isEnabled = true;
  47. expect( button ).to.have.property( 'isEnabled', true );
  48. command.isEnabled = false;
  49. expect( button ).to.have.property( 'isEnabled', false );
  50. } );
  51. it( 'executes command when it\'s executed', () => {
  52. const button = editor.ui.componentFactory.create( 'blockQuote' );
  53. const spy = sinon.stub( editor, 'execute' );
  54. button.fire( 'execute' );
  55. expect( spy.calledOnce ).to.be.true;
  56. expect( spy.args[ 0 ][ 0 ] ).to.equal( 'blockQuote' );
  57. } );
  58. } );
  59. } );