utils.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 testUtils from '/tests/_utils/utils.js';
  7. import moduleTestUtils from '/tests/_utils/module.js';
  8. import coreTestUtils from '/tests/core/_utils/utils.js';
  9. import Creator from '/ckeditor5/core/creator.js';
  10. let createFn3 = () => {};
  11. let destroyFn3 = () => {};
  12. testUtils.createSinonSandbox();
  13. coreTestUtils.defineEditorCreatorMock( 'test1' );
  14. coreTestUtils.defineEditorCreatorMock( 'test2', {
  15. foo: 1,
  16. bar: 2
  17. } );
  18. coreTestUtils.defineEditorCreatorMock( 'test3', {
  19. create: createFn3,
  20. destroy: destroyFn3
  21. } );
  22. const modules = moduleTestUtils.require( {
  23. testCreator1: 'creator-test1/creator-test1',
  24. testCreator2: 'creator-test2/creator-test2',
  25. testCreator3: 'creator-test3/creator-test3'
  26. } );
  27. ///////////////////
  28. let TestCreator1, TestCreator2, TestCreator3;
  29. before( () => {
  30. TestCreator1 = modules.testCreator1;
  31. TestCreator2 = modules.testCreator2;
  32. TestCreator3 = modules.testCreator3;
  33. } );
  34. describe( 'coreTestUtils.defineEditorCreatorMock()', () => {
  35. it( 'should register all creators', () => {
  36. expect( TestCreator1.prototype ).to.be.instanceof( Creator );
  37. expect( TestCreator2.prototype ).to.be.instanceof( Creator );
  38. expect( TestCreator3.prototype ).to.be.instanceof( Creator );
  39. } );
  40. it( 'should copy properties from the second argument', () => {
  41. expect( TestCreator2.prototype ).to.have.property( 'foo', 1 );
  42. expect( TestCreator2.prototype ).to.have.property( 'bar', 2 );
  43. expect( TestCreator3.prototype ).to.have.property( 'create', createFn3 );
  44. expect( TestCreator3.prototype ).to.have.property( 'destroy', destroyFn3 );
  45. } );
  46. } );