How to use the sinon/pkg/sinon.js.stub 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 keen / explorer / test / unit / validations / FilterValidationsSpec.js View on Github external
it('should call parseList if the coercion_type is List', function () {
        var filter = {
          coercion_type: 'List',
          property_value: ['a list']
        };
        var stub = sinon.stub(FormatUtils, 'parseList');
        FilterValidations.property_value.validate(filter);
        assert.isTrue(stub.calledWith(filter.property_value));
        FormatUtils.parseList.restore();
      });
      it('should run the geo validations if the coercion_type is Geo', function () {
github keen / explorer / test / unit / utils / FunnelUtilsSpec.js View on Github external
it('should call FilterUtils.queryJSON for every filter', function () {
      var step = { filters: [{}, {}, {}] };
      var stub = sinon.stub(FilterUtils, 'queryJSON');

      FunnelUtils.stepJSON(step);

      assert.lengthOf(stub.getCalls(), 3);
      FilterUtils.queryJSON.restore();
    });
  });
github keen / explorer / test / unit / components / explorer / query_builder / funnels / funnel_step_spec.js View on Github external
function getProps(props) {
  var props = props || {};
  var defaults = {
    index: 0,
    canRemove: true,
    step: TestHelpers.createStep(),
    eventCollections: [],
    propertyNames: [],
    onBrowseEvents: sinon.stub(),
    moveStep: sinon.stub(),
    removeStep: sinon.stub(),
    handleChange: sinon.stub(),
    toggleStepActive: sinon.stub(),
    handleFilterChange: sinon.stub(),
    handleAddFilter: sinon.stub(),
    handleRemoveFilter: sinon.stub(),
    getPropertyType: sinon.stub()
  };
  return _.assign({}, defaults, props);
}
github keen / explorer / test / unit / components / common / filter_spec.js View on Github external
beforeEach(function() {
    this.handleChangeStub = sinon.stub();
    this.removeFilterStub = sinon.stub();

    this.defaultProps = {
      key: 0,
      index: 0,
      filter: {
        property_name: 'name',
        operator: 'eq',
        property_value: 'value',
        coercion_type: 'String',
        isValid: true,
        errors: []
      },
      propertyType: 'String',
      eventCollection: 'click',
      propertyNames: [
        'one',
github keen / explorer / test / unit / components / common / filter_manager_spec.js View on Github external
function defaultProps() {
  return {
    eventCollection: null,
    filters: [],
    handleChange: sinon.stub(),
    removeFilter: sinon.stub(),
    addFilter: sinon.stub(),
    getPropertyType: sinon.stub().returns('String'),
    propertyNames: []
  };
}
github keen / explorer / test / unit / components / explorer / query_builder / funnels / funnel_builder_spec.js View on Github external
function getProps(props) {
  var props = props || {};
  var defaults = {
    modelId: 'abc123',
    steps: [],
    onBrowseEvents: sinon.stub(),
    eventCollections: [],
    stepNotices: [],
    getEventPropertyNames: sinon.stub().returns([]),
    getPropertyType: sinon.stub().returns('String')
  };
  return _.assign({}, defaults, props);
}
github keen / explorer / test / unit / components / explorer / query_builder / funnels / funnel_step_spec.js View on Github external
function getProps(props) {
  var props = props || {};
  var defaults = {
    index: 0,
    canRemove: true,
    step: TestHelpers.createStep(),
    eventCollections: [],
    propertyNames: [],
    onBrowseEvents: sinon.stub(),
    moveStep: sinon.stub(),
    removeStep: sinon.stub(),
    handleChange: sinon.stub(),
    toggleStepActive: sinon.stub(),
    handleFilterChange: sinon.stub(),
    handleAddFilter: sinon.stub(),
    handleRemoveFilter: sinon.stub(),
    getPropertyType: sinon.stub()
  };
  return _.assign({}, defaults, props);
}
github keen / explorer / test / unit / components / explorer / query_builder / funnels / funnel_step_spec.js View on Github external
function getProps(props) {
  var props = props || {};
  var defaults = {
    index: 0,
    canRemove: true,
    step: TestHelpers.createStep(),
    eventCollections: [],
    propertyNames: [],
    onBrowseEvents: sinon.stub(),
    moveStep: sinon.stub(),
    removeStep: sinon.stub(),
    handleChange: sinon.stub(),
    toggleStepActive: sinon.stub(),
    handleFilterChange: sinon.stub(),
    handleAddFilter: sinon.stub(),
    handleRemoveFilter: sinon.stub(),
    getPropertyType: sinon.stub()
  };
  return _.assign({}, defaults, props);
}
github keen / explorer / test / unit / components / common / event_browser_spec.js View on Github external
before(function(){
    this.runQueryStub = sinon.stub(ExplorerUtils, 'runQuery');
    sinon.stub(ProjectActions, 'fetchCollectionSchema');
  });