Repository: couchdb-fauxton Updated Branches: refs/heads/master 77ba12fb7 -> e49fbeac3
JumpToDB component now updates DB list after initial render Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/e49fbeac Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/e49fbeac Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/e49fbeac Branch: refs/heads/master Commit: e49fbeac3ed6e70fa753e6d92c49827e0741d184 Parents: 77ba12f Author: Ben Keen <[email protected]> Authored: Thu May 14 11:25:51 2015 -0700 Committer: Ben Keen <[email protected]> Committed: Thu May 14 12:25:52 2015 -0700 ---------------------------------------------------------------------- app/addons/databases/components.react.jsx | 3 +++ .../databases/tests/componentsSpec.react.jsx | 25 +++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e49fbeac/app/addons/databases/components.react.jsx ---------------------------------------------------------------------- diff --git a/app/addons/databases/components.react.jsx b/app/addons/databases/components.react.jsx index 27203f9..d42b7de 100644 --- a/app/addons/databases/components.react.jsx +++ b/app/addons/databases/components.react.jsx @@ -226,6 +226,9 @@ define([ componentDidMount: function () { databasesStore.on('change', this.onChange, this); + }, + + componentDidUpdate: function () { $(this.refs.searchDbName.getDOMNode()).typeahead({ source: this.state.databaseNames, updater: function (item) { http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e49fbeac/app/addons/databases/tests/componentsSpec.react.jsx ---------------------------------------------------------------------- diff --git a/app/addons/databases/tests/componentsSpec.react.jsx b/app/addons/databases/tests/componentsSpec.react.jsx index 2925180..64c3180 100644 --- a/app/addons/databases/tests/componentsSpec.react.jsx +++ b/app/addons/databases/tests/componentsSpec.react.jsx @@ -13,10 +13,11 @@ define([ 'api', 'addons/databases/components.react', 'addons/databases/actions', + 'addons/databases/actiontypes', 'addons/databases/stores', 'testUtils', "react" -], function (FauxtonAPI, Views, Actions, Stores, utils, React) { +], function (FauxtonAPI, Views, Actions, ActionTypes, Stores, utils, React) { var assert = utils.assert; var TestUtils = React.addons.TestUtils; @@ -184,8 +185,29 @@ define([ assert.equal("db2", passedDbName); }); + it('updates DB list if data is sent after initially mounted', function () { + var newCollection = new Backbone.Collection(); + newCollection.add(new Backbone.Model({ name: 'new-db1' })); + newCollection.add(new Backbone.Model({ name: 'new-db2' })); + + var spy = sinon.spy(jumpEl, 'componentDidUpdate'); + + FauxtonAPI.dispatch({ + type: ActionTypes.DATABASES_INIT, + options: { + collection: newCollection.toJSON(), + backboneCollection: newCollection, + page: 1 + } + }); + + // because of the need to override typeahead, this just does a spy on the componentDidUpdate method to ensure + // it gets called + assert.ok(spy.calledOnce); + }); }); + describe('DatabasePagination', function () { it('uses custom URL prefix on the navigation if passed through props', function () { var container = document.createElement('div'); @@ -199,5 +221,6 @@ define([ }); }); + });
