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