1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2026-01-03 23:22:30 +03:00

Apply prettier formatting

This commit is contained in:
Michael Weimann
2022-12-09 09:38:20 +01:00
parent 08a9073bd5
commit 349c2c2587
239 changed files with 22004 additions and 21928 deletions

View File

@@ -72,18 +72,19 @@ describe("MSC3089TreeSpace", () => {
});
}
it('should populate the room reference', () => {
it("should populate the room reference", () => {
expect(tree.room).toBe(room);
});
it('should proxy the ID member to room ID', () => {
it("should proxy the ID member to room ID", () => {
expect(tree.id).toEqual(tree.roomId);
expect(tree.id).toEqual(roomId);
});
it('should support setting the name of the space', async () => {
it("should support setting the name of the space", async () => {
const newName = "NEW NAME";
const fn = jest.fn()
const fn = jest
.fn()
.mockImplementation((stateRoomId: string, eventType: EventType, content: any, stateKey: string) => {
expect(stateRoomId).toEqual(roomId);
expect(eventType).toEqual(EventType.RoomName);
@@ -96,7 +97,7 @@ describe("MSC3089TreeSpace", () => {
expect(fn).toHaveBeenCalledTimes(1);
});
it('should support inviting users to the space', async () => {
it("should support inviting users to the space", async () => {
const target = targetUser;
const fn = jest.fn().mockImplementation((inviteRoomId: string, userId: string) => {
expect(inviteRoomId).toEqual(roomId);
@@ -108,7 +109,7 @@ describe("MSC3089TreeSpace", () => {
expect(fn).toHaveBeenCalledTimes(1);
});
it('should retry invites to the space', async () => {
it("should retry invites to the space", async () => {
const target = targetUser;
const fn = jest.fn().mockImplementation((inviteRoomId: string, userId: string) => {
expect(inviteRoomId).toEqual(roomId);
@@ -121,7 +122,7 @@ describe("MSC3089TreeSpace", () => {
expect(fn).toHaveBeenCalledTimes(2);
});
it('should not retry invite permission errors', async () => {
it("should not retry invite permission errors", async () => {
const target = targetUser;
const fn = jest.fn().mockImplementation((inviteRoomId: string, userId: string) => {
expect(inviteRoomId).toEqual(roomId);
@@ -141,7 +142,7 @@ describe("MSC3089TreeSpace", () => {
expect(fn).toHaveBeenCalledTimes(1);
});
it('should invite to subspaces', async () => {
it("should invite to subspaces", async () => {
const target = targetUser;
const fn = jest.fn().mockImplementation((inviteRoomId: string, userId: string) => {
expect(inviteRoomId).toEqual(roomId);
@@ -162,7 +163,7 @@ describe("MSC3089TreeSpace", () => {
expect(fn).toHaveBeenCalledTimes(4);
});
it('should share keys with invitees', async () => {
it("should share keys with invitees", async () => {
const target = targetUser;
const sendKeysFn = jest.fn().mockImplementation((inviteRoomId: string, userIds: string[]) => {
expect(inviteRoomId).toEqual(roomId);
@@ -190,7 +191,7 @@ describe("MSC3089TreeSpace", () => {
expect(historyFn).toHaveBeenCalledTimes(1);
});
it('should not share keys with invitees if inappropriate history visibility', async () => {
it("should not share keys with invitees if inappropriate history visibility", async () => {
const target = targetUser;
const sendKeysFn = jest.fn().mockImplementation((inviteRoomId: string, userIds: string[]) => {
expect(inviteRoomId).toEqual(roomId);
@@ -215,7 +216,8 @@ describe("MSC3089TreeSpace", () => {
async function evaluatePowerLevels(pls: any, role: TreePermissions, expectedPl: number) {
makePowerLevels(pls);
const fn = jest.fn()
const fn = jest
.fn()
.mockImplementation((stateRoomId: string, eventType: EventType, content: any, stateKey: string) => {
expect(stateRoomId).toEqual(roomId);
expect(eventType).toEqual(EventType.RoomPowerLevels);
@@ -240,80 +242,100 @@ describe("MSC3089TreeSpace", () => {
expect(finalPermissions).toEqual(role);
}
it('should support setting Viewer permissions', () => {
return evaluatePowerLevels({
...DEFAULT_TREE_POWER_LEVELS_TEMPLATE,
users_default: 1024,
events_default: 1025,
events: {
[EventType.RoomPowerLevels]: 1026,
it("should support setting Viewer permissions", () => {
return evaluatePowerLevels(
{
...DEFAULT_TREE_POWER_LEVELS_TEMPLATE,
users_default: 1024,
events_default: 1025,
events: {
[EventType.RoomPowerLevels]: 1026,
},
},
}, TreePermissions.Viewer, 1024);
TreePermissions.Viewer,
1024,
);
});
it('should support setting Editor permissions', () => {
return evaluatePowerLevels({
...DEFAULT_TREE_POWER_LEVELS_TEMPLATE,
users_default: 1024,
events_default: 1025,
events: {
[EventType.RoomPowerLevels]: 1026,
it("should support setting Editor permissions", () => {
return evaluatePowerLevels(
{
...DEFAULT_TREE_POWER_LEVELS_TEMPLATE,
users_default: 1024,
events_default: 1025,
events: {
[EventType.RoomPowerLevels]: 1026,
},
},
}, TreePermissions.Editor, 1025);
TreePermissions.Editor,
1025,
);
});
it('should support setting Owner permissions', () => {
return evaluatePowerLevels({
...DEFAULT_TREE_POWER_LEVELS_TEMPLATE,
users_default: 1024,
events_default: 1025,
events: {
[EventType.RoomPowerLevels]: 1026,
it("should support setting Owner permissions", () => {
return evaluatePowerLevels(
{
...DEFAULT_TREE_POWER_LEVELS_TEMPLATE,
users_default: 1024,
events_default: 1025,
events: {
[EventType.RoomPowerLevels]: 1026,
},
},
}, TreePermissions.Owner, 1026);
TreePermissions.Owner,
1026,
);
});
it('should support demoting permissions', () => {
return evaluatePowerLevels({
...DEFAULT_TREE_POWER_LEVELS_TEMPLATE,
users_default: 1024,
events_default: 1025,
events: {
[EventType.RoomPowerLevels]: 1026,
it("should support demoting permissions", () => {
return evaluatePowerLevels(
{
...DEFAULT_TREE_POWER_LEVELS_TEMPLATE,
users_default: 1024,
events_default: 1025,
events: {
[EventType.RoomPowerLevels]: 1026,
},
users: {
[targetUser]: 2222,
},
},
users: {
[targetUser]: 2222,
},
}, TreePermissions.Viewer, 1024);
TreePermissions.Viewer,
1024,
);
});
it('should support promoting permissions', () => {
return evaluatePowerLevels({
...DEFAULT_TREE_POWER_LEVELS_TEMPLATE,
users_default: 1024,
events_default: 1025,
events: {
[EventType.RoomPowerLevels]: 1026,
it("should support promoting permissions", () => {
return evaluatePowerLevels(
{
...DEFAULT_TREE_POWER_LEVELS_TEMPLATE,
users_default: 1024,
events_default: 1025,
events: {
[EventType.RoomPowerLevels]: 1026,
},
users: {
[targetUser]: 5,
},
},
users: {
[targetUser]: 5,
},
}, TreePermissions.Editor, 1025);
TreePermissions.Editor,
1025,
);
});
it('should support defaults: Viewer', () => {
it("should support defaults: Viewer", () => {
return evaluatePowerLevels({}, TreePermissions.Viewer, 0);
});
it('should support defaults: Editor', () => {
it("should support defaults: Editor", () => {
return evaluatePowerLevels({}, TreePermissions.Editor, 50);
});
it('should support defaults: Owner', () => {
it("should support defaults: Owner", () => {
return evaluatePowerLevels({}, TreePermissions.Owner, 100);
});
it('should create subdirectories', async () => {
it("should create subdirectories", async () => {
const subspaceName = "subdirectory";
const subspaceId = "!subspace:localhost";
const domain = "domain.example.com";
@@ -331,7 +353,8 @@ describe("MSC3089TreeSpace", () => {
expect(name).toEqual(subspaceName);
return new MSC3089TreeSpace(client, subspaceId);
});
const sendStateFn = jest.fn()
const sendStateFn = jest
.fn()
.mockImplementation(async (roomId: string, eventType: EventType, content: any, stateKey: string) => {
expect([tree.roomId, subspaceId]).toContain(roomId);
if (roomId === subspaceId) {
@@ -361,7 +384,7 @@ describe("MSC3089TreeSpace", () => {
expect(sendStateFn).toHaveBeenCalledWith(tree.roomId, EventType.SpaceChild, content, subspaceId);
});
it('should find subdirectories', () => {
it("should find subdirectories", () => {
const firstChildRoom = "!one:example.org";
const secondChildRoom = "!two:example.org";
const thirdChildRoom = "!three:example.org"; // to ensure it doesn't end up in the subdirectories
@@ -399,7 +422,7 @@ describe("MSC3089TreeSpace", () => {
expect(getFn).toHaveBeenCalledWith(thirdChildRoom); // check to make sure it tried
});
it('should find specific directories', () => {
it("should find specific directories", () => {
client.getRoom = () => ({} as Room); // to appease the TreeSpace constructor
// Only mocking used API
@@ -415,7 +438,7 @@ describe("MSC3089TreeSpace", () => {
expect(result).toBeFalsy();
});
it('should be able to delete itself', async () => {
it("should be able to delete itself", async () => {
const delete1 = jest.fn().mockImplementation(() => Promise.resolve());
const subdir1 = { delete: delete1 } as any as MSC3089TreeSpace; // mock tested bits
@@ -466,7 +489,7 @@ describe("MSC3089TreeSpace", () => {
expect(leaveFn).toHaveBeenCalledTimes(1);
});
describe('get and set order', () => {
describe("get and set order", () => {
// Danger: these are partial implementations for testing purposes only
// @ts-ignore - "MatrixEvent is a value but used as a type", which is true but not important
@@ -483,7 +506,7 @@ describe("MSC3089TreeSpace", () => {
const content: IContent = {
via: [staticDomain],
};
if (order) content['order'] = order;
if (order) content["order"] = order;
parentState.push({
getType: () => EventType.SpaceChild,
getStateKey: () => roomId,
@@ -511,7 +534,7 @@ describe("MSC3089TreeSpace", () => {
}
function expectOrder(childRoomId: string, order: number) {
const child = childTrees.find(c => c.roomId === childRoomId);
const child = childTrees.find((c) => c.roomId === childRoomId);
expect(child).toBeDefined();
expect(child!.getOrder()).toEqual(order);
}
@@ -523,10 +546,10 @@ describe("MSC3089TreeSpace", () => {
expect([EventType.SpaceParent, EventType.RoomCreate]).toContain(eventType);
if (eventType === EventType.RoomCreate) {
expect(stateKey).toEqual("");
return childState[roomId].find(e => e.getType() === EventType.RoomCreate);
return childState[roomId].find((e) => e.getType() === EventType.RoomCreate);
} else {
expect(stateKey).toBeUndefined();
return childState[roomId].filter(e => e.getType() === eventType);
return childState[roomId].filter((e) => e.getType() === eventType);
}
},
},
@@ -541,22 +564,22 @@ describe("MSC3089TreeSpace", () => {
roomId: tree.roomId,
currentState: {
getStateEvents: (eventType: EventType, stateKey?: string) => {
expect([
EventType.SpaceChild,
EventType.RoomCreate,
EventType.SpaceParent,
]).toContain(eventType);
expect([EventType.SpaceChild, EventType.RoomCreate, EventType.SpaceParent]).toContain(
eventType,
);
if (eventType === EventType.RoomCreate) {
expect(stateKey).toEqual("");
return parentState.filter(e => e.getType() === EventType.RoomCreate)[0];
return parentState.filter((e) => e.getType() === EventType.RoomCreate)[0];
} else {
if (stateKey !== undefined) {
expect(Object.keys(rooms)).toContain(stateKey);
expect(stateKey).not.toEqual(tree.roomId);
return parentState.find(e => e.getType() === eventType && e.getStateKey() === stateKey);
return parentState.find(
(e) => e.getType() === eventType && e.getStateKey() === stateKey,
);
} // else fine
return parentState.filter(e => e.getType() === eventType);
return parentState.filter((e) => e.getType() === eventType);
}
},
},
@@ -567,18 +590,23 @@ describe("MSC3089TreeSpace", () => {
(<any>tree).room = parentRoom; // override readonly
client.getRoom = (r) => rooms[r ?? ""];
clientSendStateFn = jest.fn()
clientSendStateFn = jest
.fn()
.mockImplementation((roomId: string, eventType: EventType, content: any, stateKey: string) => {
expect(roomId).toEqual(tree.roomId);
expect(eventType).toEqual(EventType.SpaceChild);
expect(content).toMatchObject(expect.objectContaining({
via: expect.any(Array),
order: expect.any(String),
}));
expect(content).toMatchObject(
expect.objectContaining({
via: expect.any(Array),
order: expect.any(String),
}),
);
expect(Object.keys(rooms)).toContain(stateKey);
expect(stateKey).not.toEqual(tree.roomId);
const stateEvent = parentState.find(e => e.getType() === eventType && e.getStateKey() === stateKey);
const stateEvent = parentState.find(
(e) => e.getType() === eventType && e.getStateKey() === stateKey,
);
expect(stateEvent).toBeDefined();
stateEvent.getContent = () => content;
@@ -587,7 +615,7 @@ describe("MSC3089TreeSpace", () => {
client.sendStateEvent = clientSendStateFn;
});
it('should know when something is top level', () => {
it("should know when something is top level", () => {
const a = "!a:example.org";
addSubspace(a);
@@ -595,12 +623,12 @@ describe("MSC3089TreeSpace", () => {
expect(childTrees[0].isTopLevel).toBe(false); // a bit of a hack to get at this, but it's fine
});
it('should return -1 for top level spaces', () => {
it("should return -1 for top level spaces", () => {
// The tree is what we've defined as top level, so it should work
expect(tree.getOrder()).toEqual(-1);
});
it('should throw when setting an order at the top level space', async () => {
it("should throw when setting an order at the top level space", async () => {
try {
// The tree is what we've defined as top level, so it should work
await tree.setOrder(2);
@@ -612,7 +640,7 @@ describe("MSC3089TreeSpace", () => {
}
});
it('should return a stable order for unordered children', () => {
it("should return a stable order for unordered children", () => {
const a = "!a:example.org";
const b = "!b:example.org";
const c = "!c:example.org";
@@ -627,7 +655,7 @@ describe("MSC3089TreeSpace", () => {
expectOrder(c, 2);
});
it('should return a stable order for ordered children', () => {
it("should return a stable order for ordered children", () => {
const a = "!a:example.org";
const b = "!b:example.org";
const c = "!c:example.org";
@@ -642,7 +670,7 @@ describe("MSC3089TreeSpace", () => {
expectOrder(a, 2);
});
it('should return a stable order for partially ordered children', () => {
it("should return a stable order for partially ordered children", () => {
const a = "!a:example.org";
const b = "!b:example.org";
const c = "!c:example.org";
@@ -660,7 +688,7 @@ describe("MSC3089TreeSpace", () => {
expectOrder(a, 2);
});
it('should return a stable order if the create event timestamps are the same', () => {
it("should return a stable order if the create event timestamps are the same", () => {
const a = "!a:example.org";
const b = "!b:example.org";
const c = "!c:example.org";
@@ -675,7 +703,7 @@ describe("MSC3089TreeSpace", () => {
expectOrder(c, 2);
});
it('should return a stable order if there are no known create events', () => {
it("should return a stable order if there are no known create events", () => {
const a = "!a:example.org";
const b = "!b:example.org";
const c = "!c:example.org";
@@ -692,7 +720,7 @@ describe("MSC3089TreeSpace", () => {
// XXX: These tests rely on `getOrder()` re-calculating and not caching values.
it('should allow reordering within unordered children', async () => {
it("should allow reordering within unordered children", async () => {
const a = "!a:example.org";
const b = "!b:example.org";
const c = "!c:example.org";
@@ -704,32 +732,47 @@ describe("MSC3089TreeSpace", () => {
// Order of this state is validated by other tests.
const treeA = childTrees.find(c => c.roomId === a);
const treeA = childTrees.find((c) => c.roomId === a);
expect(treeA).toBeDefined();
await treeA!.setOrder(1);
expect(clientSendStateFn).toHaveBeenCalledTimes(3);
expect(clientSendStateFn).toHaveBeenCalledWith(tree.roomId, EventType.SpaceChild, expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
expect(clientSendStateFn).toHaveBeenCalledWith(
tree.roomId,
EventType.SpaceChild,
expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
// Because of how the reordering works (maintain stable ordering before moving), we end up calling this
// function twice for the same room.
order: DEFAULT_ALPHABET[0],
}), a);
expect(clientSendStateFn).toHaveBeenCalledWith(tree.roomId, EventType.SpaceChild, expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: DEFAULT_ALPHABET[1],
}), b);
expect(clientSendStateFn).toHaveBeenCalledWith(tree.roomId, EventType.SpaceChild, expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: DEFAULT_ALPHABET[2],
}), a);
// Because of how the reordering works (maintain stable ordering before moving), we end up calling this
// function twice for the same room.
order: DEFAULT_ALPHABET[0],
}),
a,
);
expect(clientSendStateFn).toHaveBeenCalledWith(
tree.roomId,
EventType.SpaceChild,
expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: DEFAULT_ALPHABET[1],
}),
b,
);
expect(clientSendStateFn).toHaveBeenCalledWith(
tree.roomId,
EventType.SpaceChild,
expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: DEFAULT_ALPHABET[2],
}),
a,
);
expectOrder(a, 1);
expectOrder(b, 0);
expectOrder(c, 2);
});
it('should allow reordering within ordered children', async () => {
it("should allow reordering within ordered children", async () => {
const a = "!a:example.org";
const b = "!b:example.org";
const c = "!c:example.org";
@@ -741,21 +784,26 @@ describe("MSC3089TreeSpace", () => {
// Order of this state is validated by other tests.
const treeA = childTrees.find(c => c.roomId === a);
const treeA = childTrees.find((c) => c.roomId === a);
expect(treeA).toBeDefined();
await treeA!.setOrder(1);
expect(clientSendStateFn).toHaveBeenCalledTimes(1);
expect(clientSendStateFn).toHaveBeenCalledWith(tree.roomId, EventType.SpaceChild, expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: 'Y',
}), a);
expect(clientSendStateFn).toHaveBeenCalledWith(
tree.roomId,
EventType.SpaceChild,
expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: "Y",
}),
a,
);
expectOrder(a, 1);
expectOrder(b, 0);
expectOrder(c, 2);
});
it('should allow reordering within partially ordered children', async () => {
it("should allow reordering within partially ordered children", async () => {
const a = "!a:example.org";
const b = "!b:example.org";
const c = "!c:example.org";
@@ -769,22 +817,27 @@ describe("MSC3089TreeSpace", () => {
// Order of this state is validated by other tests.
const treeA = childTrees.find(c => c.roomId === a);
const treeA = childTrees.find((c) => c.roomId === a);
expect(treeA).toBeDefined();
await treeA!.setOrder(2);
expect(clientSendStateFn).toHaveBeenCalledTimes(1);
expect(clientSendStateFn).toHaveBeenCalledWith(tree.roomId, EventType.SpaceChild, expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: 'Z',
}), a);
expect(clientSendStateFn).toHaveBeenCalledWith(
tree.roomId,
EventType.SpaceChild,
expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: "Z",
}),
a,
);
expectOrder(a, 2);
expectOrder(b, 3);
expectOrder(c, 1);
expectOrder(d, 0);
});
it('should support moving upwards', async () => {
it("should support moving upwards", async () => {
const a = "!a:example.org";
const b = "!b:example.org";
const c = "!c:example.org";
@@ -798,22 +851,27 @@ describe("MSC3089TreeSpace", () => {
// Order of this state is validated by other tests.
const treeB = childTrees.find(c => c.roomId === b);
const treeB = childTrees.find((c) => c.roomId === b);
expect(treeB).toBeDefined();
await treeB!.setOrder(2);
expect(clientSendStateFn).toHaveBeenCalledTimes(1);
expect(clientSendStateFn).toHaveBeenCalledWith(tree.roomId, EventType.SpaceChild, expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: 'Y',
}), b);
expect(clientSendStateFn).toHaveBeenCalledWith(
tree.roomId,
EventType.SpaceChild,
expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: "Y",
}),
b,
);
expectOrder(a, 0);
expectOrder(b, 2);
expectOrder(c, 1);
expectOrder(d, 3);
});
it('should support moving downwards', async () => {
it("should support moving downwards", async () => {
const a = "!a:example.org";
const b = "!b:example.org";
const c = "!c:example.org";
@@ -827,22 +885,27 @@ describe("MSC3089TreeSpace", () => {
// Order of this state is validated by other tests.
const treeC = childTrees.find(ch => ch.roomId === c);
const treeC = childTrees.find((ch) => ch.roomId === c);
expect(treeC).toBeDefined();
await treeC!.setOrder(1);
expect(clientSendStateFn).toHaveBeenCalledTimes(1);
expect(clientSendStateFn).toHaveBeenCalledWith(tree.roomId, EventType.SpaceChild, expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: 'U',
}), c);
expect(clientSendStateFn).toHaveBeenCalledWith(
tree.roomId,
EventType.SpaceChild,
expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: "U",
}),
c,
);
expectOrder(a, 0);
expectOrder(b, 2);
expectOrder(c, 1);
expectOrder(d, 3);
});
it('should support moving over the partial ordering boundary', async () => {
it("should support moving over the partial ordering boundary", async () => {
const a = "!a:example.org";
const b = "!b:example.org";
const c = "!c:example.org";
@@ -856,19 +919,29 @@ describe("MSC3089TreeSpace", () => {
// Order of this state is validated by other tests.
const treeB = childTrees.find(ch => ch.roomId === b);
const treeB = childTrees.find((ch) => ch.roomId === b);
expect(treeB).toBeDefined();
await treeB!.setOrder(2);
expect(clientSendStateFn).toHaveBeenCalledTimes(2);
expect(clientSendStateFn).toHaveBeenCalledWith(tree.roomId, EventType.SpaceChild, expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: 'W',
}), c);
expect(clientSendStateFn).toHaveBeenCalledWith(tree.roomId, EventType.SpaceChild, expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: 'X',
}), b);
expect(clientSendStateFn).toHaveBeenCalledWith(
tree.roomId,
EventType.SpaceChild,
expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: "W",
}),
c,
);
expect(clientSendStateFn).toHaveBeenCalledWith(
tree.roomId,
EventType.SpaceChild,
expect.objectContaining({
via: [staticDomain], // should retain domain independent of client.getDomain()
order: "X",
}),
b,
);
expectOrder(a, 0);
expectOrder(b, 2);
expectOrder(c, 1);
@@ -876,7 +949,7 @@ describe("MSC3089TreeSpace", () => {
});
});
it('should upload files', async () => {
it("should upload files", async () => {
const mxc = "mxc://example.org/file";
const fileInfo = {
mimetype: "text/plain",
@@ -910,7 +983,8 @@ describe("MSC3089TreeSpace", () => {
});
client.sendMessage = sendMsgFn;
const sendStateFn = jest.fn()
const sendStateFn = jest
.fn()
.mockImplementation((roomId: string, eventType: string, content: any, stateKey: string) => {
expect(roomId).toEqual(tree.roomId);
expect(eventType).toEqual(UNSTABLE_MSC3089_BRANCH.unstable); // test to ensure we're definitely using unstable
@@ -935,7 +1009,7 @@ describe("MSC3089TreeSpace", () => {
expect(sendStateFn).toHaveBeenCalledTimes(1);
});
it('should upload file versions', async () => {
it("should upload file versions", async () => {
const mxc = "mxc://example.org/file";
const fileInfo = {
mimetype: "text/plain",
@@ -972,7 +1046,8 @@ describe("MSC3089TreeSpace", () => {
});
client.sendMessage = sendMsgFn;
const sendStateFn = jest.fn()
const sendStateFn = jest
.fn()
.mockImplementation((roomId: string, eventType: string, content: any, stateKey: string) => {
expect(roomId).toEqual(tree.roomId);
expect(eventType).toEqual(UNSTABLE_MSC3089_BRANCH.unstable); // test to ensure we're definitely using unstable
@@ -997,7 +1072,7 @@ describe("MSC3089TreeSpace", () => {
expect(sendStateFn).toHaveBeenCalledTimes(1);
});
it('should support getting files', () => {
it("should support getting files", () => {
const fileEventId = "$file";
const fileEvent = { forTest: true }; // MatrixEvent mock
room.currentState = {
@@ -1013,7 +1088,7 @@ describe("MSC3089TreeSpace", () => {
expect(file!.indexEvent).toBe(fileEvent);
});
it('should return falsy for unknown files', () => {
it("should return falsy for unknown files", () => {
const fileEventId = "$file";
room.currentState = {
getStateEvents: (eventType: string, stateKey?: string): MatrixEvent[] | MatrixEvent | null => {
@@ -1027,7 +1102,7 @@ describe("MSC3089TreeSpace", () => {
expect(file).toBeFalsy();
});
it('should list files', () => {
it("should list files", () => {
const firstFile = { getContent: () => ({ active: true }) };
const secondFile = { getContent: () => ({ active: false }) }; // deliberately inactive
room.currentState = {
@@ -1044,7 +1119,7 @@ describe("MSC3089TreeSpace", () => {
expect(files[0].indexEvent).toBe(firstFile);
});
it('should list all files', () => {
it("should list all files", () => {
const firstFile = { getContent: () => ({ active: true }) };
const secondFile = { getContent: () => ({ active: false }) }; // deliberately inactive
room.currentState = {