Skip to content

Commit

Permalink
fix tests (kinda)
Browse files Browse the repository at this point in the history
  • Loading branch information
aberezkin committed Mar 15, 2020
1 parent c246684 commit d52d352
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ demo/dist
npm-debug.log
yarn.lock
package-lock.json
*.log
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"dependencies": {
"prop-types": "^15.5.10",
"react-autowhatever": "^10.1.2",
"react-autowhatever": "^10.2.0",
"shallow-equal": "^1.0.0"
},
"peerDependencies": {
Expand Down Expand Up @@ -65,8 +65,8 @@
"openurl": "^1.1.1",
"postcss-loader": "^1.3.3",
"prettier": "1.14.2",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-modal": "^1.7.7",
"react-transform-hmr": "^1.0.4",
"sinon": "^1.17.7",
Expand Down
5 changes: 5 additions & 0 deletions src/Autosuggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ export default class Autosuggest extends Component {
this.suggestionsContainer = this.autowhatever.itemsContainer;
}

// for versions of react earlier than 16.3.0
componentWillReceiveProps(nextProps) {
this.UNSAFE_componentWillReceiveProps(nextProps);
}

// eslint-disable-next-line camelcase, react/sort-comp
UNSAFE_componentWillReceiveProps(nextProps) {
if (shallowEqualArrays(nextProps.suggestions, this.props.suggestions)) {
Expand Down
15 changes: 13 additions & 2 deletions test/helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import chai, { expect } from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import SyntheticEvent from 'react-dom/lib/SyntheticEvent';
import TestUtils, { Simulate } from 'react-dom/test-utils';

chai.use(sinonChai);
Expand Down Expand Up @@ -39,7 +38,19 @@ export const init = application => {
clearButton = TestUtils.scryRenderedDOMComponentsWithTag(app, 'button')[0];
};

export const syntheticEventMatcher = sinon.match.instanceOf(SyntheticEvent);
// Since react-dom doesn't export SyntheticEvent anymore
export const syntheticEventMatcher = sinon.match(value => {
if (typeof value !== 'object' || value === null) {
return false;
}

const proto = Object.getPrototypeOf(value);

if ('_dispatchListeners' in value && proto && proto.constructor.Interface) {
return true;
}
return false;
}, 'of SyntheticEvent type');
export const childrenMatcher = sinon.match.any;
export const containerPropsMatcher = sinon.match({
id: sinon.match.string,
Expand Down

0 comments on commit d52d352

Please sign in to comment.