How to use the sinon.spy 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 mixpanel / mixpanel-js / tests / unit / autotrack-utils.js View on Github external
it(`shouldn't inadvertently replace DOM nodes`, function() {
      // setup
      el.replace = sinon.spy();

      // test
      parent1.name = el;
      shouldTrackElement(parent1); // previously this would cause el.replace to be called
      expect(el.replace.called).to.equal(false);
      parent1.name = undefined;

      parent1.id = el;
      shouldTrackElement(parent2); // previously this would cause el.replace to be called
      expect(el.replace.called).to.equal(false);
      parent1.id = undefined;

      parent1.type = el;
      shouldTrackElement(parent2); // previously this would cause el.replace to be called
      expect(el.replace.called).to.equal(false);
      parent1.type = undefined;
github kartikayg / StatusPage / api-gateway / src / app.spec.js View on Github external
describe('app - integration tests', function () {

  this.timeout(10000);

  const staticCurrentTime = new Date();

  let messagingQueue, componentGroupId;

  const appLogQueueCallbackSpy = sinon.spy();
  const reqLogQueueCallbackSpy = sinon.spy();

  let dbConnection;

  let app, agent;

  let jwtToken;

  before(function (done) {

    MockDate.set(staticCurrentTime);

    // create a logs exchange on the messaging queue
    messagingQueue = amqp.createConnection({url: process.env.RABBMITMQ_CONN_ENDPOINT});
    messagingQueue.on('ready', () => {
github kartikayg / StatusPage / components-service / src / lib / db / mongo.spec.js View on Github external
describe('remove, should call the remove() on collection obj', function() {

      const removeSpy = sinon.spy(testCollectionStub, 'deleteMany');

      beforeEach(function() {
        removeSpy.reset();
      });

      after(function() {
        removeSpy.restore();
      });

      it ('should return the count after delete', async function() {

        // do remove
        const pred = {id: 1};
        const cnt = await dao.remove(pred);

        assert.strictEqual(cnt, 1);
github formsy / formsy-react / __tests__ / Validation-spec.tsx View on Github external
it('should trigger an onInvalid handler, if passed, when form is invalid', () => {
    const onValid = sinon.spy();
    const onInvalid = sinon.spy();

    mount(
      
        
      ,
    );

    expect(onValid.called).toEqual(false);
    expect(onInvalid.called).toEqual(true);
  });
github h2non / rocky / test / http.js View on Github external
test('timeout', function (done) {
    var spy = sinon.spy()
    var serverSpy = sinon.spy()

    replay = createReplayServer(assertReplay)
    server = createTimeoutServer()

    proxy = rocky()
      .forward(targetUrl)
      .replay(replayUrl)
      .listen(ports.proxy)

    proxy.get('/test')
      .options({ timeout: 50 })
      .on('proxyReq', spy)
      .on('proxy:error', spy)

    supertest(proxyUrl)
      .get('/test')
github TuurDutoit / crash / test / mocha.js View on Github external
it("should call updateAABBPoint when passed a Point", function() {
            var collider = new Crash.Point(new Crash.V);
            var cache = Crash.updateAABBPoint;
            var spy = Crash.updateAABBPoint = sinon.spy();
            Crash.updateAABB(collider);
            Crash.updateAABBPoint = cache;
            
            expect(spy.called).to.be.ok();
            expect(spy.callCount).to.be(1);
        });
    });
github tencentyun / wafer-client-sdk / test / tunnel.js View on Github external
beforeEach(function () {
       Tunnel = require_tunnel_module();
       sinon.spy(wx, 'sendSocketMessage');
    });
github ncthbrt / nact / test / console-engine.js View on Github external
const initTest = () => {
      const consoleProxy = {
        trace: sinon.spy(function trace () { }),
        debug: sinon.spy(function debug () { }),
        info: sinon.spy(function info () { }),
        warn: sinon.spy(function warn () { }),
        error: sinon.spy(function error () { }),
        critical: sinon.spy(function critical () { })
      };
      const system = start(configureLogging(logToConsole({ consoleProxy })));
      return [consoleProxy, system];
    };
github lsycxyj / vue-l-lazyload / test / unit / specs / lazy.spec.js View on Github external
beforeEach(() => {
			setupDefaultRootLazy();
			setupWrapper();

			oReq = LazyRewireAPI.__get__('Req');
			StubReq = sinon.spy(function ({ src }) {
				const me = this;
				me.src = src;
			});
			LazyRewireAPI.__set__('Req', StubReq);
		});
		afterEach(() => {
github ali322 / CNodeRN / app / __tests__ / spec / topic.js View on Github external
function setup(){
    const store = configureStore(topicsReducer)
    const state = store.getState()
    let props = {
        styles:{},
        styleConstants:{},
        userPrefs:{},
        actions,
        ...state
    }
    sinon.spy(Topics.prototype,"render")
    sinon.spy(Topics.prototype,"componentDidMount")
    let wrapper = shallow()
    return {wrapper,store}
}