You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by am...@apache.org on 2018/07/23 17:56:27 UTC
[couchdb-fauxton] branch master updated: Fix warnings that appear
at runtime and at Jest tests (#1107)
This is an automated email from the ASF dual-hosted git repository.
amaranhao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git
The following commit(s) were added to refs/heads/master by this push:
new 7861f94 Fix warnings that appear at runtime and at Jest tests (#1107)
7861f94 is described below
commit 7861f945ba29563a921e6a7d4ab20b2e00dce4a5
Author: Antonio Maranhao <30...@users.noreply.github.com>
AuthorDate: Mon Jul 23 13:56:25 2018 -0400
Fix warnings that appear at runtime and at Jest tests (#1107)
* Fix call to setState on unmounted component
* Fix warnings when running Jest tests
---
app/addons/databases/__tests__/databasepagination.test.js | 3 ++-
app/addons/databases/components.js | 3 +++
app/addons/documents/__tests__/main-fields-view.test.js | 13 +++++++++++++
app/addons/documents/__tests__/query-options.test.js | 6 +++++-
app/addons/documents/doc-editor/components.js | 2 +-
5 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/app/addons/databases/__tests__/databasepagination.test.js b/app/addons/databases/__tests__/databasepagination.test.js
index 4061fa4..6ec9f59 100644
--- a/app/addons/databases/__tests__/databasepagination.test.js
+++ b/app/addons/databases/__tests__/databasepagination.test.js
@@ -33,7 +33,8 @@ describe('Database Pagination', function () {
const tempStore = {
getTotalAmountOfDatabases: () => { return 10; },
getPage: () => { return 1; },
- on: () => {}
+ on: () => {},
+ off: () => {}
};
const pagination = mount(<DatabaseComponents.DatabasePagination store={tempStore} />);
diff --git a/app/addons/databases/components.js b/app/addons/databases/components.js
index f752c9f..c017ae3 100644
--- a/app/addons/databases/components.js
+++ b/app/addons/databases/components.js
@@ -316,6 +316,9 @@ class DatabasePagination extends React.Component {
UNSAFE_componentWillReceiveProps(nextProps) {
this.setState(this.getStoreState(nextProps));
+ if (this.props.store) {
+ this.props.store.off('change', this.onChange, this);
+ }
const {store} = nextProps;
store.on('change', this.onChange, this);
}
diff --git a/app/addons/documents/__tests__/main-fields-view.test.js b/app/addons/documents/__tests__/main-fields-view.test.js
index d6fe8aa..fe108ca 100644
--- a/app/addons/documents/__tests__/main-fields-view.test.js
+++ b/app/addons/documents/__tests__/main-fields-view.test.js
@@ -17,9 +17,16 @@ import MainFieldsView from '../index-results/components/queryoptions/MainFieldsV
import sinon from 'sinon';
describe('MainFieldsView', () => {
+ const defaultProps = {
+ stable: false,
+ toggleStable: () => {},
+ update: 'true',
+ changeUpdateField: () => {}
+ };
const docURL = 'http://foo.com';
it('does not render reduce when showReduce is false', () => {
const wrapper = mount(<MainFieldsView
+ {...defaultProps}
includeDocs={false}
showReduce={false}
reduce={false}
@@ -32,6 +39,7 @@ describe('MainFieldsView', () => {
it('render reduce when showReduce is true but does not render grouplevel when reduce is false', () => {
const wrapper = mount(<MainFieldsView
+ {...defaultProps}
includeDocs={false}
showReduce={true}
reduce={false}
@@ -46,6 +54,7 @@ describe('MainFieldsView', () => {
it('calls toggleIncludeDocs onChange', () => {
const spy = sinon.spy();
const wrapper = mount(<MainFieldsView
+ {...defaultProps}
includeDocs={false}
showReduce={true}
reduce={false}
@@ -60,6 +69,7 @@ describe('MainFieldsView', () => {
it('calls groupLevelChange onChange', () => {
const spy = sinon.spy();
const wrapper = mount(<MainFieldsView
+ {...defaultProps}
includeDocs={false}
showReduce={true}
reduce={true}
@@ -76,6 +86,7 @@ describe('MainFieldsView', () => {
it('calls toggleReduce onChange', () => {
const spy = sinon.spy();
const wrapper = mount(<MainFieldsView
+ {...defaultProps}
includeDocs={false}
showReduce={true}
reduce={true}
@@ -92,6 +103,7 @@ describe('MainFieldsView', () => {
it('calls toggleStable', () => {
const spy = sinon.spy();
const wrapper = mount(<MainFieldsView
+ {...defaultProps}
includeDocs={false}
showReduce={false}
reduce={false}
@@ -107,6 +119,7 @@ describe('MainFieldsView', () => {
it('calls changeUpdateField', () => {
const spy = sinon.spy();
const wrapper = mount(<MainFieldsView
+ {...defaultProps}
includeDocs={false}
showReduce={false}
reduce={false}
diff --git a/app/addons/documents/__tests__/query-options.test.js b/app/addons/documents/__tests__/query-options.test.js
index d62cd59..90d5256 100644
--- a/app/addons/documents/__tests__/query-options.test.js
+++ b/app/addons/documents/__tests__/query-options.test.js
@@ -23,7 +23,11 @@ describe('QueryOptions', () => {
queryOptionsToggleIncludeDocs: () => {},
reduce: false,
contentVisible: true,
- perPage: 10
+ perPage: 10,
+ queryOptionsToggleStable: () => {},
+ queryOptionsChangeUpdate: () => {},
+ stable: false,
+ update: 'true'
};
it('calls resetPagination and queryOptionsExecute on submit', () => {
diff --git a/app/addons/documents/doc-editor/components.js b/app/addons/documents/doc-editor/components.js
index d5cf362..752c14f 100644
--- a/app/addons/documents/doc-editor/components.js
+++ b/app/addons/documents/doc-editor/components.js
@@ -396,7 +396,7 @@ class CloneDocModal extends React.Component {
if (res.uuids) {
this.setState({ uuid: res.uuids[0] });
}
- });
+ }).catch(() => {});
}
}