mirror of https://github.com/vector-im/riot-web
runAllTimers -> runOnlyPendingTimers in SpaceStore-test (#7634)
* runAllTimers -> runOnlyPendingTimers in SpaceStore-test Signed-off-by: Kerry Archibald <kerrya@element.io> * runAllTimers for switch to first valid space when selected metaspace is disabled Signed-off-by: Kerry Archibald <kerrya@element.io>pull/21833/head
parent
056c7c8d65
commit
f7a3027e50
|
@ -98,19 +98,19 @@ describe("SpaceStore", () => {
|
||||||
client.getRoom.mockImplementation(roomId => rooms.find(room => room.roomId === roomId));
|
client.getRoom.mockImplementation(roomId => rooms.find(room => room.roomId === roomId));
|
||||||
client.getRoomUpgradeHistory.mockImplementation(roomId => [rooms.find(room => room.roomId === roomId)]);
|
client.getRoomUpgradeHistory.mockImplementation(roomId => [rooms.find(room => room.roomId === roomId)]);
|
||||||
await testUtils.setupAsyncStoreWithClient(store, client);
|
await testUtils.setupAsyncStoreWithClient(store, client);
|
||||||
jest.runAllTimers();
|
jest.runOnlyPendingTimers();
|
||||||
};
|
};
|
||||||
|
|
||||||
const setShowAllRooms = async (value: boolean) => {
|
const setShowAllRooms = async (value: boolean) => {
|
||||||
if (store.allRoomsInHome === value) return;
|
if (store.allRoomsInHome === value) return;
|
||||||
const emitProm = testUtils.emitPromise(store, UPDATE_HOME_BEHAVIOUR);
|
const emitProm = testUtils.emitPromise(store, UPDATE_HOME_BEHAVIOUR);
|
||||||
await SettingsStore.setValue("Spaces.allRoomsInHome", null, SettingLevel.DEVICE, value);
|
await SettingsStore.setValue("Spaces.allRoomsInHome", null, SettingLevel.DEVICE, value);
|
||||||
jest.runAllTimers(); // run async dispatch
|
jest.runOnlyPendingTimers(); // run async dispatch
|
||||||
await emitProm;
|
await emitProm;
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
jest.runAllTimers(); // run async dispatch
|
jest.runOnlyPendingTimers(); // run async dispatch
|
||||||
client.getVisibleRooms.mockReturnValue(rooms = []);
|
client.getVisibleRooms.mockReturnValue(rooms = []);
|
||||||
|
|
||||||
await SettingsStore.setValue("Spaces.enabledMetaSpaces", null, SettingLevel.DEVICE, {
|
await SettingsStore.setValue("Spaces.enabledMetaSpaces", null, SettingLevel.DEVICE, {
|
||||||
|
@ -692,7 +692,7 @@ describe("SpaceStore", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const getCurrentRoom = () => {
|
const getCurrentRoom = () => {
|
||||||
jest.runAllTimers();
|
jest.runOnlyPendingTimers();
|
||||||
return currentRoom;
|
return currentRoom;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -885,14 +885,14 @@ describe("SpaceStore", () => {
|
||||||
const rootSpace = mkSpace(space1, [room1, room2, space2]);
|
const rootSpace = mkSpace(space1, [room1, room2, space2]);
|
||||||
rootSpace.getMyMembership.mockReturnValue("invite");
|
rootSpace.getMyMembership.mockReturnValue("invite");
|
||||||
client.emit("Room", rootSpace);
|
client.emit("Room", rootSpace);
|
||||||
jest.runAllTimers();
|
jest.runOnlyPendingTimers();
|
||||||
expect(SpaceStore.instance.invitedSpaces).toStrictEqual([rootSpace]);
|
expect(SpaceStore.instance.invitedSpaces).toStrictEqual([rootSpace]);
|
||||||
expect(SpaceStore.instance.spacePanelSpaces).toStrictEqual([]);
|
expect(SpaceStore.instance.spacePanelSpaces).toStrictEqual([]);
|
||||||
|
|
||||||
// accept invite to space
|
// accept invite to space
|
||||||
rootSpace.getMyMembership.mockReturnValue("join");
|
rootSpace.getMyMembership.mockReturnValue("join");
|
||||||
client.emit("Room.myMembership", rootSpace, "join", "invite");
|
client.emit("Room.myMembership", rootSpace, "join", "invite");
|
||||||
jest.runAllTimers();
|
jest.runOnlyPendingTimers();
|
||||||
expect(SpaceStore.instance.invitedSpaces).toStrictEqual([]);
|
expect(SpaceStore.instance.invitedSpaces).toStrictEqual([]);
|
||||||
expect(SpaceStore.instance.spacePanelSpaces).toStrictEqual([rootSpace]);
|
expect(SpaceStore.instance.spacePanelSpaces).toStrictEqual([rootSpace]);
|
||||||
|
|
||||||
|
@ -901,7 +901,7 @@ describe("SpaceStore", () => {
|
||||||
const rootSpaceRoom1 = mkRoom(room1);
|
const rootSpaceRoom1 = mkRoom(room1);
|
||||||
rootSpaceRoom1.getMyMembership.mockReturnValue("join");
|
rootSpaceRoom1.getMyMembership.mockReturnValue("join");
|
||||||
client.emit("Room", rootSpaceRoom1);
|
client.emit("Room", rootSpaceRoom1);
|
||||||
jest.runAllTimers();
|
jest.runOnlyPendingTimers();
|
||||||
expect(SpaceStore.instance.invitedSpaces).toStrictEqual([]);
|
expect(SpaceStore.instance.invitedSpaces).toStrictEqual([]);
|
||||||
expect(SpaceStore.instance.spacePanelSpaces).toStrictEqual([rootSpace]);
|
expect(SpaceStore.instance.spacePanelSpaces).toStrictEqual([rootSpace]);
|
||||||
expect(SpaceStore.instance.isRoomInSpace(space1, room1)).toBeTruthy();
|
expect(SpaceStore.instance.isRoomInSpace(space1, room1)).toBeTruthy();
|
||||||
|
@ -915,7 +915,7 @@ describe("SpaceStore", () => {
|
||||||
const rootSpaceRoom2 = mkRoom(room2);
|
const rootSpaceRoom2 = mkRoom(room2);
|
||||||
rootSpaceRoom2.getMyMembership.mockReturnValue("invite");
|
rootSpaceRoom2.getMyMembership.mockReturnValue("invite");
|
||||||
client.emit("Room", rootSpaceRoom2);
|
client.emit("Room", rootSpaceRoom2);
|
||||||
jest.runAllTimers();
|
jest.runOnlyPendingTimers();
|
||||||
expect(SpaceStore.instance.invitedSpaces).toStrictEqual([]);
|
expect(SpaceStore.instance.invitedSpaces).toStrictEqual([]);
|
||||||
expect(SpaceStore.instance.spacePanelSpaces).toStrictEqual([rootSpace]);
|
expect(SpaceStore.instance.spacePanelSpaces).toStrictEqual([rootSpace]);
|
||||||
expect(SpaceStore.instance.isRoomInSpace(space1, room2)).toBeTruthy();
|
expect(SpaceStore.instance.isRoomInSpace(space1, room2)).toBeTruthy();
|
||||||
|
@ -952,12 +952,12 @@ describe("SpaceStore", () => {
|
||||||
user: dm1Partner.userId,
|
user: dm1Partner.userId,
|
||||||
room: space1,
|
room: space1,
|
||||||
}));
|
}));
|
||||||
jest.runAllTimers();
|
jest.runOnlyPendingTimers();
|
||||||
expect(SpaceStore.instance.getSpaceFilteredUserIds(space1).has(dm1Partner.userId)).toBeTruthy();
|
expect(SpaceStore.instance.getSpaceFilteredUserIds(space1).has(dm1Partner.userId)).toBeTruthy();
|
||||||
const dm1Room = mkRoom(dm1);
|
const dm1Room = mkRoom(dm1);
|
||||||
dm1Room.getMyMembership.mockReturnValue("join");
|
dm1Room.getMyMembership.mockReturnValue("join");
|
||||||
client.emit("Room", dm1Room);
|
client.emit("Room", dm1Room);
|
||||||
jest.runAllTimers();
|
jest.runOnlyPendingTimers();
|
||||||
expect(SpaceStore.instance.invitedSpaces).toStrictEqual([]);
|
expect(SpaceStore.instance.invitedSpaces).toStrictEqual([]);
|
||||||
expect(SpaceStore.instance.spacePanelSpaces).toStrictEqual([rootSpace]);
|
expect(SpaceStore.instance.spacePanelSpaces).toStrictEqual([rootSpace]);
|
||||||
expect(SpaceStore.instance.isRoomInSpace(space1, dm1)).toBeTruthy();
|
expect(SpaceStore.instance.isRoomInSpace(space1, dm1)).toBeTruthy();
|
||||||
|
@ -971,7 +971,7 @@ describe("SpaceStore", () => {
|
||||||
subspace.getMyMembership.mockReturnValue("join");
|
subspace.getMyMembership.mockReturnValue("join");
|
||||||
const prom = testUtils.emitPromise(SpaceStore.instance, space1);
|
const prom = testUtils.emitPromise(SpaceStore.instance, space1);
|
||||||
client.emit("Room", subspace);
|
client.emit("Room", subspace);
|
||||||
jest.runAllTimers();
|
jest.runOnlyPendingTimers();
|
||||||
expect(SpaceStore.instance.invitedSpaces).toStrictEqual([]);
|
expect(SpaceStore.instance.invitedSpaces).toStrictEqual([]);
|
||||||
expect(SpaceStore.instance.spacePanelSpaces.map(r => r.roomId)).toStrictEqual([rootSpace.roomId]);
|
expect(SpaceStore.instance.spacePanelSpaces.map(r => r.roomId)).toStrictEqual([rootSpace.roomId]);
|
||||||
await prom;
|
await prom;
|
||||||
|
|
Loading…
Reference in New Issue