8
0

utils.js 883 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. /**
  7. * General test utils for CKEditor.
  8. */
  9. const utils = {
  10. /**
  11. * Creates Sinon sandbox in {@link bender#sinon} and plugs `afterEach()` callback which
  12. * restores all spies and stubs created in this sandbox.
  13. *
  14. * See https://github.com/ckeditor/ckeditor5-design/issues/72 and http://sinonjs.org/docs/#sinon-sandbox
  15. *
  16. * Usage:
  17. *
  18. * // Directly in the test file:
  19. * testUtils.createSinonSandbox();
  20. *
  21. * // Then inside tests you can use bender.sinon:
  22. * it( 'does something', () => {
  23. * testUtils.sinon.spy( obj, 'method' );
  24. * } );
  25. */
  26. createSinonSandbox() {
  27. before( () => {
  28. utils.sinon = sinon.sandbox.create();
  29. } );
  30. afterEach( () => {
  31. utils.sinon.restore();
  32. } );
  33. }
  34. };
  35. export default utils;