utils.js 1.6 KB

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