utils.js 942 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. import moduleUtils from '/tests/_utils/module.js';
  7. const utils = {
  8. /**
  9. * Defines CKEditor plugin which is a mock of an editor creator.
  10. *
  11. * The mocked creator is available under:
  12. *
  13. * editor.plugins.get( 'creator-thename' );
  14. *
  15. * @param {String} creatorName Name of the creator.
  16. * @param {Object} [proto] Prototype of the creator. Properties from the proto param will
  17. * be copied to the prototype of the creator.
  18. */
  19. defineEditorCreatorMock( creatorName, proto ) {
  20. moduleUtils.define( 'creator-' + creatorName, [ 'core/creator' ], ( Creator ) => {
  21. class TestCreator extends Creator {}
  22. if ( proto ) {
  23. for ( let propName in proto ) {
  24. TestCreator.prototype[ propName ] = proto[ propName ];
  25. }
  26. }
  27. return TestCreator;
  28. } );
  29. }
  30. };
  31. export default utils;