Apply prettier formatting
This commit is contained in:
parent
1cac306093
commit
526645c791
1576 changed files with 65385 additions and 62478 deletions
|
@ -59,22 +59,22 @@ describe("ForwardDialog", () => {
|
|||
getRoom: jest.fn(),
|
||||
getAccountData: jest.fn().mockReturnValue(accountDataEvent),
|
||||
getPushActionsForEvent: jest.fn(),
|
||||
mxcUrlToHttp: jest.fn().mockReturnValue(''),
|
||||
mxcUrlToHttp: jest.fn().mockReturnValue(""),
|
||||
isRoomEncrypted: jest.fn().mockReturnValue(false),
|
||||
getProfileInfo: jest.fn().mockResolvedValue({
|
||||
displayname: 'Alice',
|
||||
displayname: "Alice",
|
||||
}),
|
||||
decryptEventIfNeeded: jest.fn(),
|
||||
sendEvent: jest.fn(),
|
||||
getClientWellKnown: jest.fn().mockReturnValue({
|
||||
[TILE_SERVER_WK_KEY.name]: { map_style_url: 'maps.com' },
|
||||
[TILE_SERVER_WK_KEY.name]: { map_style_url: "maps.com" },
|
||||
}),
|
||||
});
|
||||
const defaultRooms = ["a", "A", "b"].map(name => mkStubRoom(name, name, mockClient));
|
||||
const defaultRooms = ["a", "A", "b"].map((name) => mkStubRoom(name, name, mockClient));
|
||||
|
||||
const mountForwardDialog = (message = defaultMessage, rooms = defaultRooms) => {
|
||||
mockClient.getVisibleRooms.mockReturnValue(rooms);
|
||||
mockClient.getRoom.mockImplementation(roomId => rooms.find(room => room.roomId === roomId));
|
||||
mockClient.getRoom.mockImplementation((roomId) => rooms.find((room) => room.roomId === roomId));
|
||||
|
||||
const wrapper: RenderResult = render(
|
||||
<ForwardDialog
|
||||
|
@ -96,7 +96,7 @@ describe("ForwardDialog", () => {
|
|||
});
|
||||
|
||||
afterAll(() => {
|
||||
jest.spyOn(MatrixClientPeg, 'get').mockRestore();
|
||||
jest.spyOn(MatrixClientPeg, "get").mockRestore();
|
||||
});
|
||||
|
||||
it("shows a preview with us as the sender", async () => {
|
||||
|
@ -127,10 +127,13 @@ describe("ForwardDialog", () => {
|
|||
// Make sendEvent require manual resolution so we can see the sending state
|
||||
let finishSend;
|
||||
let cancelSend;
|
||||
mockClient.sendEvent.mockImplementation(<T extends {}>() => new Promise<T>((resolve, reject) => {
|
||||
finishSend = resolve;
|
||||
cancelSend = reject;
|
||||
}));
|
||||
mockClient.sendEvent.mockImplementation(
|
||||
<T extends {}>() =>
|
||||
new Promise<T>((resolve, reject) => {
|
||||
finishSend = resolve;
|
||||
cancelSend = reject;
|
||||
}),
|
||||
);
|
||||
|
||||
let firstButton;
|
||||
let secondButton;
|
||||
|
@ -141,28 +144,32 @@ describe("ForwardDialog", () => {
|
|||
|
||||
expect(firstButton.className).toContain("mx_ForwardList_canSend");
|
||||
|
||||
act(() => { fireEvent.click(firstButton); });
|
||||
act(() => {
|
||||
fireEvent.click(firstButton);
|
||||
});
|
||||
update();
|
||||
expect(firstButton.className).toContain("mx_ForwardList_sending");
|
||||
|
||||
await act(async () => {
|
||||
cancelSend();
|
||||
// Wait one tick for the button to realize the send failed
|
||||
await new Promise(resolve => setImmediate(resolve));
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
});
|
||||
update();
|
||||
expect(firstButton.className).toContain("mx_ForwardList_sendFailed");
|
||||
|
||||
expect(secondButton.className).toContain("mx_ForwardList_canSend");
|
||||
|
||||
act(() => { fireEvent.click(secondButton); });
|
||||
act(() => {
|
||||
fireEvent.click(secondButton);
|
||||
});
|
||||
update();
|
||||
expect(secondButton.className).toContain("mx_ForwardList_sending");
|
||||
|
||||
await act(async () => {
|
||||
finishSend();
|
||||
// Wait one tick for the button to realize the send succeeded
|
||||
await new Promise(resolve => setImmediate(resolve));
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
});
|
||||
update();
|
||||
expect(secondButton.className).toContain("mx_ForwardList_sent");
|
||||
|
@ -203,7 +210,7 @@ describe("ForwardDialog", () => {
|
|||
expect(secondButton.getAttribute("aria-disabled")).toBeFalsy();
|
||||
});
|
||||
|
||||
describe('Location events', () => {
|
||||
describe("Location events", () => {
|
||||
// 14.03.2022 16:15
|
||||
const now = 1647270879403;
|
||||
const roomId = "a";
|
||||
|
@ -215,11 +222,11 @@ describe("ForwardDialog", () => {
|
|||
beforeEach(() => {
|
||||
// legacy events will default timestamp to Date.now()
|
||||
// mock a stable now for easy assertion
|
||||
jest.spyOn(Date, 'now').mockReturnValue(now);
|
||||
jest.spyOn(Date, "now").mockReturnValue(now);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
jest.spyOn(Date, 'now').mockRestore();
|
||||
jest.spyOn(Date, "now").mockRestore();
|
||||
});
|
||||
|
||||
const sendToFirstRoom = (container: HTMLElement): void =>
|
||||
|
@ -228,7 +235,7 @@ describe("ForwardDialog", () => {
|
|||
fireEvent.click(sendToFirstRoomButton!);
|
||||
});
|
||||
|
||||
it('converts legacy location events to pin drop shares', async () => {
|
||||
it("converts legacy location events to pin drop shares", async () => {
|
||||
const { container } = mountForwardDialog(legacyLocationEvent);
|
||||
|
||||
expect(container.querySelector(".mx_MLocationBody")).toBeTruthy();
|
||||
|
@ -250,11 +257,13 @@ describe("ForwardDialog", () => {
|
|||
},
|
||||
};
|
||||
expect(mockClient.sendEvent).toHaveBeenCalledWith(
|
||||
roomId, legacyLocationEvent.getType(), expectedStrippedContent,
|
||||
roomId,
|
||||
legacyLocationEvent.getType(),
|
||||
expectedStrippedContent,
|
||||
);
|
||||
});
|
||||
|
||||
it('removes personal information from static self location shares', async () => {
|
||||
it("removes personal information from static self location shares", async () => {
|
||||
const { container } = mountForwardDialog(modernLocationEvent);
|
||||
|
||||
expect(container.querySelector(".mx_MLocationBody")).toBeTruthy();
|
||||
|
@ -275,13 +284,15 @@ describe("ForwardDialog", () => {
|
|||
},
|
||||
};
|
||||
expect(mockClient.sendEvent).toHaveBeenCalledWith(
|
||||
roomId, modernLocationEvent.getType(), expectedStrippedContent,
|
||||
roomId,
|
||||
modernLocationEvent.getType(),
|
||||
expectedStrippedContent,
|
||||
);
|
||||
});
|
||||
|
||||
it('forwards beacon location as a pin drop event', async () => {
|
||||
it("forwards beacon location as a pin drop event", async () => {
|
||||
const timestamp = 123456;
|
||||
const beaconEvent = makeBeaconEvent('@alice:server.org', { geoUri, timestamp });
|
||||
const beaconEvent = makeBeaconEvent("@alice:server.org", { geoUri, timestamp });
|
||||
const text = `Location ${geoUri} at ${new Date(timestamp).toISOString()}`;
|
||||
const expectedContent = {
|
||||
msgtype: "m.location",
|
||||
|
@ -301,12 +312,10 @@ describe("ForwardDialog", () => {
|
|||
|
||||
sendToFirstRoom(container);
|
||||
|
||||
expect(mockClient.sendEvent).toHaveBeenCalledWith(
|
||||
roomId, EventType.RoomMessage, expectedContent,
|
||||
);
|
||||
expect(mockClient.sendEvent).toHaveBeenCalledWith(roomId, EventType.RoomMessage, expectedContent);
|
||||
});
|
||||
|
||||
it('forwards pin drop event', async () => {
|
||||
it("forwards pin drop event", async () => {
|
||||
const { container } = mountForwardDialog(pinDropLocationEvent);
|
||||
|
||||
expect(container.querySelector(".mx_MLocationBody")).toBeTruthy();
|
||||
|
@ -314,7 +323,9 @@ describe("ForwardDialog", () => {
|
|||
sendToFirstRoom(container);
|
||||
|
||||
expect(mockClient.sendEvent).toHaveBeenCalledWith(
|
||||
roomId, pinDropLocationEvent.getType(), pinDropLocationEvent.getContent(),
|
||||
roomId,
|
||||
pinDropLocationEvent.getType(),
|
||||
pinDropLocationEvent.getContent(),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue