1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-16 22:01:54 +03:00

Merge pull request #1877 from matrix-org/luke/test-room-list

Add tests for RoomList
This commit is contained in:
Luke Barnard
2018-05-04 13:57:57 +01:00
committed by GitHub
4 changed files with 316 additions and 21 deletions

View File

@ -74,6 +74,7 @@ export function createTestClient() {
getPushActionsForEvent: sinon.stub(),
getRoom: sinon.stub().returns(mkStubRoom()),
getRooms: sinon.stub().returns([]),
getGroups: sinon.stub().returns([]),
loginFlows: sinon.stub(),
on: sinon.stub(),
removeListener: sinon.stub(),
@ -301,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;
};
});
}