<commit_before>/** @jsx React.DOM */
var sinon = require('sinon');
var assert = require('chai').assert;
var _ = require('lodash');
var React = require('react/addons');
var TestUtils = React.addons.TestUtils;
var TestHelpers = require('../../../support/TestHelpers.js');
var FilterManager = require('../../../../client/js/app/components/common/filter_manager.js');
var ExplorerActions = require('../../../../client/js/app/actions/ExplorerActions');

describe('components/common/filter_manager', function() {

  before(function () {
    this.addFilterStub = sinon.stub(ExplorerActions, 'addFilter');
  });

  after(function () {
    ExplorerActions.addFilter.restore();
  });

  beforeEach(function() {
    this.client = TestHelpers.createClient();
    this.project = TestHelpers.createProject();
    this.project.loading = true;
    this.model = TestHelpers.createExplorerModel();
    this.component = TestUtils.renderIntoDocument(<FilterManager client={this.client} project={this.project} model={this.model} />);
  });

  describe('setup', function(){
    it('should have tried to create a default empty filter', function () {
      assert.isTrue(this.addFilterStub.calledOnce);
    });
    it('has an empty filters message by default', function(){
      var message = 'Please select an Event Collection before making a filter.';
      assert.equal(message, TestUtils.findRenderedDOMComponentWithClass(this.component, 'no-filters-msg').getDOMNode().textContent);
    });
  });
  describe('field change reactions', function () {
    describe('event_collection', function () {
      beforeEach(function(){
        this.model.query.event_collection = 'click';
        this.component.forceUpdate();
      });

      it("no longer shows the 'Please select an event collection' message", function() {
        assert.lengthOf(TestUtils.scryRenderedDOMComponentsWithClass(this.component, 'no-filters-msg'), 0);
      });
      it("has an add filter button", function() {
        assert.lengthOf(TestUtils.scryRenderedDOMComponentsWithClass(this.component, 'add-filter'), 1);
      });
    });
  });
});<commit_msg>Fixed FilterManagerSpec<commit_after>/** @jsx React.DOM */
var sinon = require('sinon');
var assert = require('chai').assert;
var _ = require('lodash');
var React = require('react/addons');
var TestUtils = React.addons.TestUtils;
var TestHelpers = require('../../../support/TestHelpers.js');
var FilterManager = require('../../../../client/js/app/components/common/filter_manager.js');

describe('components/common/filter_manager', function() {

  beforeEach(function() {
    this.handleChangeStub = sinon.stub();
    this.removeFilterStub = sinon.stub();
    this.addFilterStub = sinon.stub();
    this.getPropertyType = function(){ return 'String'; };

    var defaultProps = {
      eventCollection: null,
      filters: [],
      handleChange: this.handleChangeStub,
      removeFilter: this.removeFilterStub,
      addFilter: this.addFilterStub,
      getPropertyType: this.getPropertyType,
      propertyNames: []
    };
    this.renderComponent = function(props) {
      var props = _.assign({}, defaultProps, props);
      return TestUtils.renderIntoDocument(<FilterManager {...props} />);
    }
    this.component = this.renderComponent();
  });

  it('has a message telling the user to choose an event collection is one is not set', function(){
    var message = 'Please select an Event Collection before making a filter.';
    assert.equal(message, TestUtils.findRenderedDOMComponentWithClass(this.component, 'no-filters-msg').getDOMNode().textContent);
  });
  it("no longer shows the message when an event collection is set", function() {
    this.component = this.renderComponent({ eventCollection: 'click' });
    assert.lengthOf(TestUtils.scryRenderedDOMComponentsWithClass(this.component, 'no-filters-msg'), 0);
  });
  it("has an add filter button when an event collection is set", function() {
    this.component = this.renderComponent({ eventCollection: 'click' });
    assert.lengthOf(TestUtils.scryRenderedDOMComponentsWithClass(this.component, 'add-filter'), 1);
  });
});
{'fraction_non_alphanumeric': 0.15313338210192637, 'fraction_numerical': 0.000975371860521824, 'mean_word_length': 4.095652173913043, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4435270', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1144, 'n_words': 248}