Move test setup to describe scope
This commit is contained in:
parent
3766b39361
commit
568042b9e7
1 changed files with 39 additions and 61 deletions
|
@ -81,19 +81,12 @@ describe("SpaceHierarchy", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("toLocalRoom", () => {
|
describe("toLocalRoom", () => {
|
||||||
let client: MatrixClient;
|
|
||||||
let roomV1: Room;
|
|
||||||
let roomV2: Room;
|
|
||||||
let roomV3: Room;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
stubClient();
|
stubClient();
|
||||||
client = MatrixClientPeg.get();
|
let client = MatrixClientPeg.get();
|
||||||
roomV1 = mkStubRoom("room-id-1", "Room V1", client);
|
let roomV1 = mkStubRoom("room-id-1", "Room V1", client);
|
||||||
roomV2 = mkStubRoom("room-id-2", "Room V2", client);
|
let roomV2 = mkStubRoom("room-id-2", "Room V2", client);
|
||||||
roomV3 = mkStubRoom("room-id-3", "Room V3", client);
|
let roomV3 = mkStubRoom("room-id-3", "Room V3", client);
|
||||||
jest.spyOn(client, "getRoomUpgradeHistory").mockReturnValue([roomV1, roomV2, roomV3]);
|
jest.spyOn(client, "getRoomUpgradeHistory").mockReturnValue([roomV1, roomV2, roomV3]);
|
||||||
});
|
|
||||||
|
|
||||||
it("grabs last room that is in hierarchy when latest version is in hierarchy", () => {
|
it("grabs last room that is in hierarchy when latest version is in hierarchy", () => {
|
||||||
const hierarchy = {
|
const hierarchy = {
|
||||||
|
@ -138,33 +131,19 @@ describe("SpaceHierarchy", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("<HierarchyLevel />", () => {
|
describe("<HierarchyLevel />", () => {
|
||||||
let client: MatrixClient;
|
|
||||||
let dmRoomMap: DMRoomMap;
|
|
||||||
|
|
||||||
let root: Room;
|
|
||||||
let room1: Room;
|
|
||||||
let room2: Room;
|
|
||||||
|
|
||||||
let hierarchyRoot: IHierarchyRoom;
|
|
||||||
let hierarchyRoom1: IHierarchyRoom;
|
|
||||||
let hierarchyRoom2: IHierarchyRoom;
|
|
||||||
|
|
||||||
let roomHierarchy: RoomHierarchy;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
stubClient();
|
stubClient();
|
||||||
client = MatrixClientPeg.get();
|
let client = MatrixClientPeg.get();
|
||||||
|
|
||||||
dmRoomMap = {
|
let dmRoomMap = {
|
||||||
getUserIdForRoomId: jest.fn(),
|
getUserIdForRoomId: jest.fn(),
|
||||||
} as unknown as DMRoomMap;
|
} as unknown as DMRoomMap;
|
||||||
jest.spyOn(DMRoomMap, "shared").mockReturnValue(dmRoomMap);
|
jest.spyOn(DMRoomMap, "shared").mockReturnValue(dmRoomMap);
|
||||||
|
|
||||||
root = mkStubRoom("room-id-1", "Room 1", client);
|
let root = mkStubRoom("room-id-1", "Room 1", client);
|
||||||
room1 = mkStubRoom("room-id-2", "Room 2", client);
|
let room1 = mkStubRoom("room-id-2", "Room 2", client);
|
||||||
room2 = mkStubRoom("room-id-3", "Room 3", client);
|
let room2 = mkStubRoom("room-id-3", "Room 3", client);
|
||||||
|
|
||||||
hierarchyRoot = {
|
let hierarchyRoot = {
|
||||||
room_id: root.roomId,
|
room_id: root.roomId,
|
||||||
num_joined_members: 1,
|
num_joined_members: 1,
|
||||||
children_state: [
|
children_state: [
|
||||||
|
@ -178,10 +157,10 @@ describe("SpaceHierarchy", () => {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
} as IHierarchyRoom;
|
} as IHierarchyRoom;
|
||||||
hierarchyRoom1 = { room_id: room1.roomId, num_joined_members: 2 } as IHierarchyRoom;
|
let hierarchyRoom1 = { room_id: room1.roomId, num_joined_members: 2 } as IHierarchyRoom;
|
||||||
hierarchyRoom2 = { room_id: root.roomId, num_joined_members: 3 } as IHierarchyRoom;
|
let hierarchyRoom2 = { room_id: root.roomId, num_joined_members: 3 } as IHierarchyRoom;
|
||||||
|
|
||||||
roomHierarchy = {
|
let roomHierarchy = {
|
||||||
roomMap: new Map([
|
roomMap: new Map([
|
||||||
[root.roomId, hierarchyRoot],
|
[root.roomId, hierarchyRoot],
|
||||||
[room1.roomId, hierarchyRoom1],
|
[room1.roomId, hierarchyRoom1],
|
||||||
|
@ -189,7 +168,6 @@ describe("SpaceHierarchy", () => {
|
||||||
]),
|
]),
|
||||||
isSuggested: jest.fn(),
|
isSuggested: jest.fn(),
|
||||||
} as unknown as RoomHierarchy;
|
} as unknown as RoomHierarchy;
|
||||||
});
|
|
||||||
|
|
||||||
it("renders", () => {
|
it("renders", () => {
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
|
|
Loading…
Reference in a new issue