createsinonsandbox.js 882 B

1234567891011121314151617181920212223242526272829303132333435
  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 testUtils from '../../tests/_utils/utils';
  6. const obj = {
  7. method() {}
  8. };
  9. const origMethod = obj.method;
  10. let spy;
  11. describe( 'testUtils.createSinonSandbox()', () => {
  12. testUtils.createSinonSandbox();
  13. it( 'creates a sandbox', () => {
  14. expect( testUtils.sinon ).to.be.an( 'object' );
  15. expect( testUtils.sinon ).to.have.property( 'spy' );
  16. } );
  17. // This test is needed for the following one.
  18. it( 'really works', () => {
  19. spy = testUtils.sinon.spy( obj, 'method' );
  20. expect( obj ).to.have.property( 'method', spy );
  21. } );
  22. it( 'restores spies after each test', () => {
  23. obj.method();
  24. sinon.assert.notCalled( spy );
  25. expect( obj ).to.have.property( 'method', origMethod );
  26. } );
  27. } );