How to use the sinon.restore 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 seegno / bookshelf-json-columns / test / sqlite / index.js View on Github external
it('should not override model prototype initialize method', async () => {
      sinon.spy(ModelPrototype, 'initialize');

      Model.forge();

      ModelPrototype.initialize.callCount.should.equal(1);

      sinon.restore(ModelPrototype);
    });
github flickr / flickr-sdk / test / services.upload.js View on Github external
it('attaches the photo', function () {
		var spy = sinon.spy(Request.prototype, 'attach');
		var req = new Subject(auth, 'fnord.png');

		sinon.assert.calledOnce(spy);
		sinon.assert.calledWith(spy, 'photo', 'fnord.png');
		sinon.assert.calledOn(spy, req);

		sinon.restore(spy);
	});
github xbl / raml-mocker / test / har-convert / har-convert.spec.ts View on Github external
"runner": {
        "test": "http://localhost:3000"
      }
    }
  `);
  callback.onCall(1).resolves(template);
  sinon.replace(fs, 'readFile', callback);

  const target = '1.js';
  sinon.replace(fs, 'appendFile', (fileTarget, str) => {
    t.is(fileTarget, target);
    t.is(str, expectResult);
  });

  await save(restAPIs, target);
  sinon.restore();
});
github openscope / openscope / test / game / GameOptions.spec.js View on Github external
ava('.setOptionByName() does not call EventBus.trigger() when #onChangeEventHandler() is null', (t) => {
    EventBus.trigger = sinon.stub();
    const optionValueMock = 'bow wow';
    const optionNameMock = 'number';
    const model = new GameOptions();

    model.addOption(GAME_OPTION_LIST_MOCK[1]);
    model.setOptionByName(optionNameMock, optionValueMock);

    t.true(EventBus.trigger.callCount === 0);

    EventBus.trigger = sinon.restore();
});
github SelfKeyFoundation / Identity-Wallet / src / main / token / price-service.spec.js View on Github external
afterEach(() => {
		sinon.restore();
	});
	it('is event emmitter', () => {
github betagouv / preuve-covoiturage / api / core / src / transports / CliTransport.spec.ts View on Github external
kernel.boot().then(() => {
      const cliTransport = new CliTransport(kernel);
      const container = kernel.getContainer();
      const commander = container.get(CommandProvider);
      sinon.stub(commander, 'output').callsFake((...args: any[]) => {
        expect(args[0]).to.equal('Hello john');
        done();
      });
      container.unbind(CommandProvider);
      container.bind(CommandProvider).toConstantValue(commander);
      cliTransport.up(['', '', 'hello', 'john']);
      sinon.restore();
    });
  });