How to use the auto-release-sinon.stub function in auto-release-sinon

To help you get started, we’ve selected a few auto-release-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 elastic / kibana / src / ui / vislib / __tests__ / visualizations / tile_maps / map.js View on Github external
beforeEach(ngMock.inject(function (Private) {
    // mock parts of leaflet
    leafletMocks.tileLayer = { on: sinon.stub() };
    leafletMocks.map = { on: sinon.stub() };
    leafletStubs.tileLayer = sinon.stub(L, 'tileLayer', _.constant(leafletMocks.tileLayer));
    leafletStubs.map = sinon.stub(L, 'map', _.constant(leafletMocks.map));

    Map = Private(require('ui/vislib/visualizations/_map'));
  }));
github elastic / kibana / src / ui / vislib / __tests__ / visualizations / tile_maps / map.js View on Github external
beforeEach(ngMock.inject(function (Private) {
    // mock parts of leaflet
    leafletMocks.tileLayer = { on: sinon.stub() };
    leafletMocks.map = { on: sinon.stub() };
    leafletStubs.tileLayer = sinon.stub(L, 'tileLayer', _.constant(leafletMocks.tileLayer));
    leafletStubs.map = sinon.stub(L, 'map', _.constant(leafletMocks.map));

    Map = Private(require('ui/vislib/visualizations/_map'));
  }));
github elastic / kibana / src / ui / public / directives / __tests__ / validate_query.js View on Github external
ngMock.inject(function ($injector, _$rootScope_, _$compile_, _$timeout_, _Promise_, _Private_, _config_) {
    $timeout = _$timeout_;
    $compile = _$compile_;
    Promise = _Promise_;
    Private = _Private_;
    config = _config_;

    // Give us a scope
    $rootScope = _$rootScope_;

    var es = $injector.get('es');
    mockValidateQuery = sinon.stub(es.indices, 'validateQuery');
  });
};
github elastic / kibana / src / ui / index_patterns / __tests__ / _index_pattern.js View on Github external
it('should increment the poplarity count by default', function () {
      var saveSpy = sinon.stub(indexPattern, 'save');
      indexPattern.fields.forEach(function (field, i) {
        var oldCount = field.count;

        indexPattern.popularizeField(field.name);

        expect(saveSpy.callCount).to.equal(i + 1);
        expect(field.count).to.equal(oldCount + 1);
      });
    });
github elastic / kibana / src / ui / public / vislib_vis_type / __tests__ / _buildChartData.js View on Github external
it('defers to hierarchical aggResponse converter', function () {
      var football = {};
      var renderbot = {
        vis: {
          isHierarchical: _.constant(true)
        }
      };

      var stub = sinon.stub(aggResponse, 'hierarchical').returns(football);
      expect(buildChartData.call(renderbot, football)).to.be(football);
      expect(stub).to.have.property('callCount', 1);
      expect(stub.firstCall.args[0]).to.be(renderbot.vis);
      expect(stub.firstCall.args[1]).to.be(football);
    });
  });
github elastic / kibana / src / ui / vislib_vis_type / __tests__ / _buildChartData.js View on Github external
it('defers to hierarchical aggResponse converter', function () {
      var football = {};
      var renderbot = {
        vis: {
          isHierarchical: _.constant(true)
        }
      };

      var stub = sinon.stub(aggResponse, 'hierarchical').returns(football);
      expect(buildChartData.call(renderbot, football)).to.be(football);
      expect(stub).to.have.property('callCount', 1);
      expect(stub.firstCall.args[0]).to.be(renderbot.vis);
      expect(stub.firstCall.args[1]).to.be(football);
    });
  });
github elastic / kibana / src / ui / public / vislib_vis_type / __tests__ / _buildChartData.js View on Github external
it('returns a single chart if the tabify response contains only a single table', function () {
      var chart = { hits: 1, rows: [], columns: [] };
      var renderbot = {
        vis: {
          isHierarchical: _.constant(false),
          type: {
            responseConverter: _.constant(chart)
          }
        }
      };
      var esResp = { hits: { total: 1 } };
      var tabbed = { tables: [ new Table() ] };

      sinon.stub(aggResponse, 'tabify').returns(tabbed);
      expect(buildChartData.call(renderbot, esResp)).to.eql(chart);
    });
github elastic / kibana / src / ui / watch_multi / __tests__ / watch_multi.js View on Github external
it('should trigger the watcher on initialization', function () {
      var stub = sinon.stub();
      firstValue = 'first';
      secondValue = 'second';

      $scope.$watchMulti(stateWatchers, stub);
      $rootScope.$apply();

      expect(stub.callCount).to.be(1);

      expect(stub.firstCall.args[0]).to.eql([firstValue, secondValue]);
      expect(stub.firstCall.args[1]).to.eql([firstValue, secondValue]);
    });
  });
github elastic / kibana / src / ui / vislib / __tests__ / visualizations / tile_maps / markers.js View on Github external
it('should use the tooltip formatter', function () {
        var content;
        var sample = _.sample(mapData.features);

        var stub = sinon.stub(markerLayer, '_tooltipFormatter', function (val) {
          return;
        });

        markerLayer._showTooltip(sample);

        expect(stub.callCount).to.equal(1);
        expect(stub.firstCall.calledWith(sample)).to.be(true);
      });
    });
github elastic / kibana / src / ui / factories / __tests__ / events.js View on Github external
it('should clear a specific handler when off is called for an event', function () {
    var obj = new Events();
    var handler1 = sinon.stub();
    var handler2 = sinon.stub();
    obj.on('test', handler1);
    obj.on('test', handler2);
    expect(obj._listeners).to.have.property('test');
    obj.off('test', handler1);

    return obj.emit('test', 'Hello World')
    .then(function () {
      sinon.assert.calledOnce(handler2);
      sinon.assert.notCalled(handler1);
    });
  });

auto-release-sinon

Basic sinon wrapper that automatically releases it's stubs, works with mocha's BDD interface

Apache-2.0
Latest version published 9 years ago

Package Health Score

42 / 100
Full package analysis

Popular auto-release-sinon functions