diff --git a/test/components/structures/GroupView-test.js b/test/components/structures/GroupView-test.js index 71df26da46..76baafe1c8 100644 --- a/test/components/structures/GroupView-test.js +++ b/test/components/structures/GroupView-test.js @@ -26,32 +26,13 @@ import sdk from 'matrix-react-sdk'; import Matrix from 'matrix-js-sdk'; import * as TestUtils from 'test-utils'; +const { waitForUpdate } = TestUtils; const GroupView = sdk.getComponent('structures.GroupView'); const WrappedGroupView = TestUtils.wrapInMatrixClientContext(GroupView); const Spinner = sdk.getComponent('elements.Spinner'); -/** - * Call fn before calling componentDidUpdate on a react component instance, inst. - * @param {React.Component} inst an instance of a React component. - * @returns {Promise} promise that resolves when componentDidUpdate is called on - * given component instance. - */ -function waitForUpdate(inst) { - return new Promise((resolve, reject) => { - const cdu = inst.componentDidUpdate; - - inst.componentDidUpdate = (prevProps, prevState, snapshot) => { - resolve(); - - if (cdu) cdu(prevProps, prevState, snapshot); - - inst.componentDidUpdate = cdu; - }; - }); -} - describe('GroupView', function() { let root; let rootElement; diff --git a/test/test-utils.js b/test/test-utils.js index d2c685b371..e7d3412722 100644 --- a/test/test-utils.js +++ b/test/test-utils.js @@ -302,3 +302,23 @@ export function wrapInMatrixClientContext(WrappedComponent) { } return Wrapper; } + +/** + * Call fn before calling componentDidUpdate on a react component instance, inst. + * @param {React.Component} inst an instance of a React component. + * @returns {Promise} promise that resolves when componentDidUpdate is called on + * given component instance. + */ +export function waitForUpdate(inst) { + return new Promise((resolve, reject) => { + const cdu = inst.componentDidUpdate; + + inst.componentDidUpdate = (prevProps, prevState, snapshot) => { + resolve(); + + if (cdu) cdu(prevProps, prevState, snapshot); + + inst.componentDidUpdate = cdu; + }; + }); +}