Github user benkeen commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/303#discussion_r25817158
  
    --- Diff: app/addons/documents/tests/changes.componentsSpec.react.jsx ---
    @@ -179,7 +188,185 @@ define([
     
           assert.equal(1, $el.find('.js-remove-filter').length);
         });
    +  });
    +
    +
    +  // tests Changes Controller; includes tests in conjunction with 
ChangesHeaderController
    +  describe('ChangesController', function () {
    +    var containerEl, headerEl, changesEl;
    +
    +    var changeList = new Backbone.Collection([
    +      { id: 'doc_1', seq: 4, deleted: false, changes: { code: 'here' } },
    +      { id: 'doc_2', seq: 1, deleted: false, changes: { code: 'here' } },
    +      { id: 'doc_3', seq: 6, deleted: true, changes: { code: 'here' } },
    +      { id: 'doc_4', seq: 7, deleted: false, changes: { code: 'here' } },
    +      { id: 'doc_5', seq: 1, deleted: true, changes: { code: 'here' } }
    +    ]);
    +
    +    beforeEach(function () {
    +      Actions.setChanges({
    +        changes: changeList.models,
    +        filters: [],
    +        databaseName: 'testDatabase'
    +      });
    +      headerEl  = 
TestUtils.renderIntoDocument(<Changes.ChangesHeaderController />, containerEl);
    +      changesEl = TestUtils.renderIntoDocument(<Changes.ChangesController 
/>, containerEl);
    +    });
    +
    +    afterEach(function () {
    +      Stores.changesStore.reset();
    +      React.unmountComponentAtNode(containerEl);
    +    });
    +
    +
    +    it('should list the right number of changes', function () {
    +      assert.equal(changeList.length, 
$(changesEl.getDOMNode()).find('.change-box').length);
    +    });
    +
     
    +    it('"false"/"true" filter strings should apply to change deleted 
status', function () {
    +      // expand the header
    +      var $headerEl = $(headerEl.getDOMNode());
    +      TestUtils.Simulate.click($(headerEl.getDOMNode()).find('a')[0]);
    +
    +      // add a filter
    +      var addItemField = $headerEl.find('.js-changes-filter-field')[0];
    +      var submitBtn = $headerEl.find('[type="submit"]')[0];
    +      addItemField.value = 'true';
    +      TestUtils.Simulate.change(addItemField);
    +      TestUtils.Simulate.submit(submitBtn);
    +
    +      // confirm only the two deleted items shows up and the IDs maps to 
the deleted rows
    +      assert.equal(2, 
$(changesEl.getDOMNode()).find('.change-box').length);
    +      assert.equal('doc_3', 
$(changesEl.getDOMNode()).find('.js-doc-id')[0].innerHTML);
    +      assert.equal('doc_5', 
$(changesEl.getDOMNode()).find('.js-doc-id')[1].innerHTML);
    +    });
    +
    +
    +    it('confirms that a filter affects the actual search results', 
function () {
    +      // expand the header
    +      var $headerEl = $(headerEl.getDOMNode());
    +      TestUtils.Simulate.click($(headerEl.getDOMNode()).find('a')[0]);
    +
    +      // add a filter
    +      var addItemField = $headerEl.find('.js-changes-filter-field')[0];
    +      var submitBtn = $headerEl.find('[type="submit"]')[0];
    +      addItemField.value = '6'; // should match doc_3's sequence ID
    +      TestUtils.Simulate.change(addItemField);
    +      TestUtils.Simulate.submit(submitBtn);
    +
    +      // confirm only one item shows up and the ID maps to what we'd expect
    +      assert.equal(1, 
$(changesEl.getDOMNode()).find('.change-box').length);
    +      assert.equal('doc_3', 
$(changesEl.getDOMNode()).find('.js-doc-id')[0].innerHTML);
    +    });
    +
    +
    +    // confirms that if there are multiple filters, ALL are applied to 
return the subset of results that match
    +    // all filters
    +    it('multiple filters should all be applied to results', function () {
    --- End diff --
    
    Yeah that makes sense, thanks.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to