Apply prettier formatting

This commit is contained in:
Michael Weimann
2022-12-12 12:24:14 +01:00
parent 1cac306093
commit 526645c791
1576 changed files with 65384 additions and 62477 deletions
+27 -21
View File
@@ -42,7 +42,7 @@ import { getIncomingCallToastKey, IncomingCallToast } from "../../src/toasts/Inc
describe("IncomingCallEvent", () => {
useMockedCalls();
jest.spyOn(HTMLMediaElement.prototype, "play").mockImplementation(async () => { });
jest.spyOn(HTMLMediaElement.prototype, "play").mockImplementation(async () => {});
let client: Mocked<MatrixClient>;
let room: Room;
@@ -66,13 +66,15 @@ describe("IncomingCallEvent", () => {
alice = mkRoomMember(room.roomId, "@alice:example.org");
bob = mkRoomMember(room.roomId, "@bob:example.org");
client.getRoom.mockImplementation(roomId => roomId === room.roomId ? room : null);
client.getRoom.mockImplementation((roomId) => (roomId === room.roomId ? room : null));
client.getRooms.mockReturnValue([room]);
client.reEmitter.reEmit(room, [RoomStateEvent.Events]);
await Promise.all([CallStore.instance, WidgetMessagingStore.instance].map(
store => setupAsyncStoreWithClient(store, client),
));
await Promise.all(
[CallStore.instance, WidgetMessagingStore.instance].map((store) =>
setupAsyncStoreWithClient(store, client),
),
);
MockedCall.create(room, "1");
const maybeCall = CallStore.instance.getCall(room.roomId);
@@ -81,7 +83,7 @@ describe("IncomingCallEvent", () => {
widget = new Widget(call.widget);
WidgetMessagingStore.instance.storeMessaging(widget, room.roomId, {
stop: () => { },
stop: () => {},
} as unknown as ClientWidgetApi);
jest.spyOn(DMRoomMap, "shared").mockReturnValue(dmRoomMap);
@@ -96,7 +98,9 @@ describe("IncomingCallEvent", () => {
jest.restoreAllMocks();
});
const renderToast = () => { render(<IncomingCallToast callEvent={call.event} />); };
const renderToast = () => {
render(<IncomingCallToast callEvent={call.event} />);
};
it("correctly shows all the information", () => {
call.participants = new Map([
@@ -131,14 +135,16 @@ describe("IncomingCallEvent", () => {
const dispatcherRef = defaultDispatcher.register(dispatcherSpy);
fireEvent.click(screen.getByRole("button", { name: "Join" }));
await waitFor(() => expect(dispatcherSpy).toHaveBeenCalledWith({
action: Action.ViewRoom,
room_id: room.roomId,
view_call: true,
}));
await waitFor(() => expect(toastStore.dismissToast).toHaveBeenCalledWith(
getIncomingCallToastKey(call.event.getStateKey()!),
));
await waitFor(() =>
expect(dispatcherSpy).toHaveBeenCalledWith({
action: Action.ViewRoom,
room_id: room.roomId,
view_call: true,
}),
);
await waitFor(() =>
expect(toastStore.dismissToast).toHaveBeenCalledWith(getIncomingCallToastKey(call.event.getStateKey()!)),
);
defaultDispatcher.unregister(dispatcherRef);
});
@@ -150,9 +156,9 @@ describe("IncomingCallEvent", () => {
const dispatcherRef = defaultDispatcher.register(dispatcherSpy);
fireEvent.click(screen.getByRole("button", { name: "Close" }));
await waitFor(() => expect(toastStore.dismissToast).toHaveBeenCalledWith(
getIncomingCallToastKey(call.event.getStateKey()!),
));
await waitFor(() =>
expect(toastStore.dismissToast).toHaveBeenCalledWith(getIncomingCallToastKey(call.event.getStateKey()!)),
);
defaultDispatcher.unregister(dispatcherRef);
});
@@ -166,8 +172,8 @@ describe("IncomingCallEvent", () => {
view_call: true,
});
await waitFor(() => expect(toastStore.dismissToast).toHaveBeenCalledWith(
getIncomingCallToastKey(call.event.getStateKey()!),
));
await waitFor(() =>
expect(toastStore.dismissToast).toHaveBeenCalledWith(getIncomingCallToastKey(call.event.getStateKey()!)),
);
});
});
+18 -18
View File
@@ -13,21 +13,21 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { render } from '@testing-library/react';
import { LOCAL_NOTIFICATION_SETTINGS_PREFIX, MatrixEvent, Room } from 'matrix-js-sdk/src/matrix';
import { MatrixCall } from 'matrix-js-sdk/src/webrtc/call';
import React from 'react';
import { render } from "@testing-library/react";
import { LOCAL_NOTIFICATION_SETTINGS_PREFIX, MatrixEvent, Room } from "matrix-js-sdk/src/matrix";
import { MatrixCall } from "matrix-js-sdk/src/webrtc/call";
import React from "react";
import LegacyCallHandler from '../../src/LegacyCallHandler';
import LegacyCallHandler from "../../src/LegacyCallHandler";
import IncomingLegacyCallToast from "../../src/toasts/IncomingLegacyCallToast";
import DMRoomMap from '../../src/utils/DMRoomMap';
import { getMockClientWithEventEmitter, mockClientMethodsServer, mockClientMethodsUser } from '../test-utils';
import DMRoomMap from "../../src/utils/DMRoomMap";
import { getMockClientWithEventEmitter, mockClientMethodsServer, mockClientMethodsUser } from "../test-utils";
describe('<IncomingLegacyCallToast />', () => {
const userId = '@alice:server.org';
const deviceId = 'my-device';
describe("<IncomingLegacyCallToast />", () => {
const userId = "@alice:server.org";
const deviceId = "my-device";
jest.spyOn(DMRoomMap, 'shared').mockReturnValue({
jest.spyOn(DMRoomMap, "shared").mockReturnValue({
getUserIdForRoomId: jest.fn(),
} as unknown as DMRoomMap);
@@ -36,7 +36,7 @@ describe('<IncomingLegacyCallToast />', () => {
...mockClientMethodsServer(),
getRoom: jest.fn(),
});
const mockRoom = new Room('!room:server.org', mockClient, userId);
const mockRoom = new Room("!room:server.org", mockClient, userId);
mockClient.deviceId = deviceId;
const call = new MatrixCall({ client: mockClient, roomId: mockRoom.roomId });
@@ -51,18 +51,18 @@ describe('<IncomingLegacyCallToast />', () => {
mockClient.getRoom.mockReturnValue(mockRoom);
});
it('renders when silence button when call is not silenced', () => {
it("renders when silence button when call is not silenced", () => {
const { getByLabelText } = render(getComponent());
expect(getByLabelText('Silence call')).toMatchSnapshot();
expect(getByLabelText("Silence call")).toMatchSnapshot();
});
it('renders sound on button when call is silenced', () => {
it("renders sound on button when call is silenced", () => {
LegacyCallHandler.instance.silenceCall(call.callId);
const { getByLabelText } = render(getComponent());
expect(getByLabelText('Sound on')).toMatchSnapshot();
expect(getByLabelText("Sound on")).toMatchSnapshot();
});
it('renders disabled silenced button when call is forced to silent', () => {
it("renders disabled silenced button when call is forced to silent", () => {
// silence local notifications -> force call ringer to silent
mockClient.getAccountData.mockImplementation((eventType) => {
if (eventType.includes(LOCAL_NOTIFICATION_SETTINGS_PREFIX.name)) {
@@ -75,6 +75,6 @@ describe('<IncomingLegacyCallToast />', () => {
}
});
const { getByLabelText } = render(getComponent());
expect(getByLabelText('Notifications silenced')).toMatchSnapshot();
expect(getByLabelText("Notifications silenced")).toMatchSnapshot();
});
});