couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benkeen <...@git.apache.org>
Subject [GitHub] couchdb-fauxton pull request: Changes page content moved to React
Date Wed, 04 Mar 2015 14:51:54 GMT
Github user benkeen commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/303#discussion_r25779497
  
    --- 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 () {
    +      var $headerEl = $(headerEl.getDOMNode());
    +      TestUtils.Simulate.click($(headerEl.getDOMNode()).find('a')[0]);
    +
    +      // add the filters
    +      var addItemField = $headerEl.find('.js-changes-filter-field')[0];
    +      var submitBtn = $headerEl.find('[type="submit"]')[0];
    +
    +      // *** should match doc_1, doc_2 and doc_5
    +      addItemField.value = '1';
    +      TestUtils.Simulate.change(addItemField);
    +      TestUtils.Simulate.submit(submitBtn);
    +
    +      // *** should match doc_3 and doc_5
    +      addItemField.value = 'true';
    +      TestUtils.Simulate.change(addItemField);
    +      TestUtils.Simulate.submit(submitBtn);
    +
    +      // confirm only one item shows up and that it's doc_5
    +      assert.equal(1, $(changesEl.getDOMNode()).find('.change-box').length);
    +      assert.equal('doc_5', $(changesEl.getDOMNode()).find('.js-doc-id')[0].innerHTML);
    +    });
    +  });
    +
    +
    +  describe('ChangesController max results', function () {
    +    var containerEl, changesEl;
    +    var maxChanges = 10;
    +
    +    beforeEach(function () {
    +
    +      // to keep the test speedy, override the default value (1000)
    +      Stores.changesStore.setMaxChanges(maxChanges);
    +
    +      // better underscorey way to do this?
    +      var changes = [];
    +      for (var i=0; i<maxChanges + 10; i++) {
    --- End diff --
    
    Niiiice :D


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message