How to use the sinon.createSandbox function in sinon

To help you get started, we’ve selected a few sinon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JetBrains / ring-ui / test-helpers / mocha-globals.js View on Github external
import {unmountComponentAtNode} from 'react-dom';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import chaiDOM from 'chai-dom';
import sinonChai from 'sinon-chai';
import chaiEnzyme from 'chai-enzyme';
import sinon from 'sinon';

chai.use(chaiAsPromised);
chai.use(chaiDOM);
chai.use(sinonChai);
chai.use(chaiEnzyme());

Object.assign(window, {
  sinon,
  sandbox: sinon.createSandbox(),
  chai,
  should: chai.should()
});

afterEach(function restoreSandbox() {
  window.sandbox.restore();

  Array.from(document.body.children).forEach(child => {
    if (child._reactRootContainer) {
      unmountComponentAtNode(child);
    }
  });
});
github elastic / kibana / src / dev / build / tasks / nodejs / __tests__ / download_node_builds_task.js View on Github external
describe('src/dev/build/tasks/nodejs/download_node_builds_task', () => {
  const sandbox = sinon.createSandbox();
  afterEach(() => {
    sandbox.restore();
  });

  function setup({ failOnUrl } = {}) {
    const platforms = [
      { getName: () => 'foo' },
      { getName: () => 'bar' },
    ];

    const log = {};
    const config = {
      getNodePlatforms: () => platforms,
      getNodeVersion: () => 'nodeVersion',
    };
github redhat-developer / vscode-openshift-tools / test / odo.int.ts View on Github external
setup(() => {
        sb = sinon.createSandbox();
        sb.stub(vscode.window, 'showInformationMessage').resolves('Download and install');
    });
github testem / testem / tests / process-ctl_tests.js View on Github external
beforeEach(function() {
      sandbox = sinon.createSandbox();
      processCtl = new ProcessCtl('test', config);
    });
github googleapis / nodejs-common / test / service-object.ts View on Github external
describe('ServiceObject', () => {
  let serviceObject: ServiceObject;
  const sandbox = sinon.createSandbox();

  const CONFIG = {
    baseUrl: 'base-url',
    parent: {} as Service,
    id: 'id',
    createMethod: util.noop,
    requestModule: {} as typeof r,
  };

  beforeEach(() => {
    serviceObject = new ServiceObject(CONFIG);
  });

  afterEach(() => {
    sandbox.restore();
  });
github valotas / preact-context / src / _tests / context.Spec.tsx View on Github external
describe("context", () => {
  const sandbox = sinon.createSandbox();

  let scratch: HTMLDivElement;

  const render = (comp: JSX.Element) =>
    preactRender(comp, scratch, scratch.lastChild as Element);

  before(() => {
    scratch = document.createElement("div");
    document.body.appendChild(scratch);
  });

  beforeEach(() => {
    options.debounceRendering = r => r();
    render();
  });
github zendesk / zendesk_app_framework_sdk / spec / index_spec.js View on Github external
describe('ZAFClient', () => {
  const sandbox = sinon.createSandbox()

  afterEach(() => {
    sandbox.restore()
  })

  describe('.init', () => {
    describe('given origin and app_guid exist', () => {
      describe('when a callback is passed', () => {
        const callback = function () { return 'abcxyz' }
        callback.bind = function () { return callback }

        beforeEach(() => {
          sandbox.spy(Client.prototype, 'on')
          ZAFClient.init(callback, { hash: 'origin=https://subdomain.zendesk.com&app_guid=A2' })
        })
github tokend / new-js-sdk / src / api2 / managers / signers-manager.spec.js View on Github external
beforeEach(() => {
    sandbox = sinon.createSandbox()
    signersManagerInstance = new SignersManager(
      ApiCaller.getInstance('https://api.test.com')
    )
  })
github IBM-Blockchain / vehicle-manufacture / contract / src / lib / contracts / vehicle.spec.ts View on Github external
beforeEach(() => {
        generateIdStub = sinon.stub();

        mockery.registerMock('../utils/functions', {
            generateId: generateIdStub,
        });

        cleanCache();
        VehicleContract = requireVehicleContract();

        sandbox = sinon.createSandbox();

        contract = new VehicleContract();
        ctx = sinon.createStubInstance(VehicleManufactureNetContext);
        stub = sinon.createStubInstance(ChaincodeStub);
        clientIdentity = sinon.createStubInstance(VehicleManufactureNetClientIdentity);
        participantList = sinon.createStubInstance(ParticipantList);
        orderList = sinon.createStubInstance(AssetList);
        vehicleList = sinon.createStubInstance(AssetList);
        policyList = sinon.createStubInstance(AssetList);
        usageList = sinon.createStubInstance(AssetList);

        organization = sinon.createStubInstance(Organization);
        participant = sinon.createStubInstance(Participant);

        (clientIdentity as any)._participant = participant;
        (clientIdentity as any)._organization = organization;
github DFEAGILEDEVOPS / MTC / admin / spec / back-end / service / group.service.spec.js View on Github external
  beforeEach(() => { sandbox = sinon.createSandbox() })
  afterEach(() => { sandbox.restore() })