1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-30 02:21:17 +03:00

Live location sharing: move test utils into utils (#8365)

* move makeRoomWithState events to test utils

Signed-off-by: Kerry Archibald <kerrya@element.io>

* move beacon test helpers into utils

Signed-off-by: Kerry Archibald <kerrya@element.io>

* remove file

Signed-off-by: Kerry Archibald <kerrya@element.io>

* more types

Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
Kerry
2022-04-19 18:47:19 +02:00
committed by GitHub
parent 56cf9212d3
commit 70cdd57a5c
5 changed files with 84 additions and 47 deletions

View File

@ -14,8 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { MockedObject } from "jest-mock";
import {
MatrixClient,
MatrixEvent,
EventType,
Room,
} from "matrix-js-sdk/src/matrix";
import { mkEvent } from "./test-utils";
@ -32,3 +36,17 @@ export const makeMembershipEvent = (
ts: Date.now(),
});
/**
* Creates a room
* sets state events on the room
* Sets client getRoom to return room
* returns room
*/
export const makeRoomWithStateEvents = (
stateEvents: MatrixEvent[] = [],
{ roomId, mockClient }: { roomId: string, mockClient: MockedObject<MatrixClient>}): Room => {
const room1 = new Room(roomId, mockClient, '@user:server.org');
room1.currentState.setStateEvents(stateEvents);
mockClient.getRoom.mockReturnValue(room1);
return room1;
};