8
0

conversionhelpers.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 ConversionHelpers from '../../src/conversion/conversionhelpers';
  6. describe( 'ConversionHelpers', () => {
  7. describe( 'add()', () => {
  8. const dispA = Symbol( 'dispA' );
  9. const dispB = Symbol( 'dispB' );
  10. it( 'should call a helper for one defined dispatcher', () => {
  11. const spy = sinon.spy();
  12. const helpers = new ConversionHelpers( [ dispA ] );
  13. helpers.add( spy );
  14. sinon.assert.calledOnce( spy );
  15. sinon.assert.calledWithExactly( spy, dispA );
  16. } );
  17. it( 'should call helper for all defined dispatcherers', () => {
  18. const spy = sinon.spy();
  19. const helpers = new ConversionHelpers( [ dispA, dispB ] );
  20. helpers.add( spy );
  21. sinon.assert.calledTwice( spy );
  22. sinon.assert.calledWithExactly( spy, dispA );
  23. sinon.assert.calledWithExactly( spy, dispB );
  24. } );
  25. it( 'should be chainable', () => {
  26. const spy = sinon.spy();
  27. const helpers = new ConversionHelpers( [ dispA ] );
  28. expect( helpers.add( spy ) ).to.equal( helpers );
  29. } );
  30. } );
  31. } );