Comply with noImplicitAny (#9940)
* Stash noImplicitAny work * Stash * Fix imports * Iterate * Fix tests * Delint * Fix tests
This commit is contained in:
parent
ac7f69216e
commit
61a63e47f4
359 changed files with 1621 additions and 1353 deletions
|
@ -18,7 +18,7 @@ limitations under the License.
|
|||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import { EventEmitter } from "events";
|
||||
import { Room, RoomMember } from "matrix-js-sdk/src/matrix";
|
||||
import { MatrixEvent, Room, RoomMember } from "matrix-js-sdk/src/matrix";
|
||||
import FakeTimers from "@sinonjs/fake-timers";
|
||||
import { render } from "@testing-library/react";
|
||||
import { Thread } from "matrix-js-sdk/src/models/thread";
|
||||
|
@ -46,7 +46,7 @@ jest.mock("../../../src/utils/beacon", () => ({
|
|||
const roomId = "!roomId:server_name";
|
||||
|
||||
describe("MessagePanel", function () {
|
||||
let clock = null;
|
||||
let clock: FakeTimers.InstalledClock | null = null;
|
||||
const realSetTimeout = window.setTimeout;
|
||||
const events = mkEvents();
|
||||
const userId = "@me:here";
|
||||
|
@ -79,7 +79,7 @@ describe("MessagePanel", function () {
|
|||
callEventGroupers: new Map(),
|
||||
room,
|
||||
className: "cls",
|
||||
events: [],
|
||||
events: [] as MatrixEvent[],
|
||||
};
|
||||
|
||||
const defaultRoomContext = {
|
||||
|
@ -322,8 +322,8 @@ describe("MessagePanel", function () {
|
|||
];
|
||||
}
|
||||
|
||||
function isReadMarkerVisible(rmContainer) {
|
||||
return rmContainer && rmContainer.children.length > 0;
|
||||
function isReadMarkerVisible(rmContainer?: Element) {
|
||||
return rmContainer?.children.length > 0;
|
||||
}
|
||||
|
||||
it("should show the events", function () {
|
||||
|
|
|
@ -83,7 +83,7 @@ describe("ThreadView", () => {
|
|||
return renderResult;
|
||||
}
|
||||
|
||||
async function sendMessage(container, text): Promise<void> {
|
||||
async function sendMessage(container: HTMLElement, text: string): Promise<void> {
|
||||
const composer = getByTestId(container, "basicmessagecomposer");
|
||||
await userEvent.click(composer);
|
||||
await userEvent.keyboard(text);
|
||||
|
@ -91,7 +91,7 @@ describe("ThreadView", () => {
|
|||
await userEvent.click(sendMessageBtn);
|
||||
}
|
||||
|
||||
function expectedMessageBody(rootEvent, message) {
|
||||
function expectedMessageBody(rootEvent: MatrixEvent, message: string) {
|
||||
return {
|
||||
"body": message,
|
||||
"m.relates_to": {
|
||||
|
|
|
@ -16,7 +16,7 @@ limitations under the License.
|
|||
|
||||
import React from "react";
|
||||
// eslint-disable-next-line deprecate/import
|
||||
import { mount } from "enzyme";
|
||||
import { mount, ReactWrapper } from "enzyme";
|
||||
import { mocked } from "jest-mock";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { act } from "react-dom/test-utils";
|
||||
|
@ -71,7 +71,7 @@ describe("<RecordingPlayback />", () => {
|
|||
mocked(createAudioContext).mockReturnValue(mockAudioContext as unknown as AudioContext);
|
||||
});
|
||||
|
||||
const getPlayButton = (component) => findByTestId(component, "play-pause-button").at(0);
|
||||
const getPlayButton = (component: ReactWrapper) => findByTestId(component, "play-pause-button").at(0);
|
||||
|
||||
it("renders recording playback", () => {
|
||||
const playback = new Playback(new ArrayBuffer(8));
|
||||
|
|
|
@ -19,7 +19,7 @@ import { mocked } from "jest-mock";
|
|||
import { MatrixClient, PendingEventOrdering } from "matrix-js-sdk/src/client";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||
import React from "react";
|
||||
import React, { ComponentProps } from "react";
|
||||
|
||||
import MemberAvatar from "../../../../src/components/views/avatars/MemberAvatar";
|
||||
import RoomContext from "../../../../src/contexts/RoomContext";
|
||||
|
@ -35,7 +35,7 @@ describe("MemberAvatar", () => {
|
|||
let room: Room;
|
||||
let member: RoomMember;
|
||||
|
||||
function getComponent(props) {
|
||||
function getComponent(props: Partial<ComponentProps<typeof MemberAvatar>>) {
|
||||
return (
|
||||
<RoomContext.Provider value={getRoomContext(room, {})}>
|
||||
<MemberAvatar member={null} width={35} height={35} {...props} />
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import React, { ComponentProps } from "react";
|
||||
import { fireEvent, render } from "@testing-library/react";
|
||||
import { act } from "react-dom/test-utils";
|
||||
|
||||
|
@ -29,7 +29,7 @@ import {
|
|||
} from "../../../test-utils";
|
||||
|
||||
describe("<DialogSidebar />", () => {
|
||||
const defaultProps = {
|
||||
const defaultProps: ComponentProps<typeof DialogSidebar> = {
|
||||
beacons: [],
|
||||
requestClose: jest.fn(),
|
||||
onBeaconClick: jest.fn(),
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import React, { ComponentProps } from "react";
|
||||
import { IPassphraseInfo } from "matrix-js-sdk/src/crypto/api";
|
||||
import { act, fireEvent, render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
|
@ -29,7 +29,7 @@ const securityKey = "EsTc WKmb ivvk jLS7 Y1NH 5CcQ mP1E JJwj B3Fd pFWm t4Dp dbyu
|
|||
describe("AccessSecretStorageDialog", () => {
|
||||
let mockClient: Mocked<MatrixClient>;
|
||||
|
||||
const defaultProps = {
|
||||
const defaultProps: ComponentProps<typeof AccessSecretStorageDialog> = {
|
||||
onFinished: jest.fn(),
|
||||
checkPrivateKey: jest.fn(),
|
||||
keyInfo: undefined,
|
||||
|
|
|
@ -16,7 +16,7 @@ limitations under the License.
|
|||
|
||||
import React from "react";
|
||||
// eslint-disable-next-line deprecate/import
|
||||
import { mount } from "enzyme";
|
||||
import { mount, ReactWrapper } from "enzyme";
|
||||
import { mocked } from "jest-mock";
|
||||
import { act } from "react-dom/test-utils";
|
||||
import { Room } from "matrix-js-sdk/src/matrix";
|
||||
|
@ -60,42 +60,43 @@ describe("<ExportDialog />", () => {
|
|||
|
||||
const getComponent = (props = {}) => mount(<ExportDialog {...defaultProps} {...props} />);
|
||||
|
||||
const getSizeInput = (component) => component.find('input[id="size-limit"]');
|
||||
const getExportTypeInput = (component) => component.find('select[id="export-type"]');
|
||||
const getAttachmentsCheckbox = (component) => component.find('input[id="include-attachments"]');
|
||||
const getMessageCountInput = (component) => component.find('input[id="message-count"]');
|
||||
const getExportFormatInput = (component, format) => component.find(`input[id="exportFormat-${format}"]`);
|
||||
const getPrimaryButton = (component) => component.find('[data-testid="dialog-primary-button"]');
|
||||
const getSecondaryButton = (component) => component.find('[data-testid="dialog-cancel-button"]');
|
||||
const getSizeInput = (component: ReactWrapper) => component.find('input[id="size-limit"]');
|
||||
const getExportTypeInput = (component: ReactWrapper) => component.find('select[id="export-type"]');
|
||||
const getAttachmentsCheckbox = (component: ReactWrapper) => component.find('input[id="include-attachments"]');
|
||||
const getMessageCountInput = (component: ReactWrapper) => component.find('input[id="message-count"]');
|
||||
const getExportFormatInput = (component: ReactWrapper, format: ExportFormat) =>
|
||||
component.find(`input[id="exportFormat-${format}"]`);
|
||||
const getPrimaryButton = (component: ReactWrapper) => component.find('[data-testid="dialog-primary-button"]');
|
||||
const getSecondaryButton = (component: ReactWrapper) => component.find('[data-testid="dialog-cancel-button"]');
|
||||
|
||||
const submitForm = async (component) =>
|
||||
const submitForm = async (component: ReactWrapper) =>
|
||||
act(async () => {
|
||||
getPrimaryButton(component).simulate("click");
|
||||
component.setProps({});
|
||||
});
|
||||
const selectExportFormat = async (component, format: ExportFormat) =>
|
||||
const selectExportFormat = async (component: ReactWrapper, format: ExportFormat) =>
|
||||
act(async () => {
|
||||
getExportFormatInput(component, format).simulate("change");
|
||||
component.setProps({});
|
||||
});
|
||||
const selectExportType = async (component, type: ExportType) =>
|
||||
const selectExportType = async (component: ReactWrapper, type: ExportType) =>
|
||||
act(async () => {
|
||||
getExportTypeInput(component).simulate("change", { target: { value: type } });
|
||||
component.setProps({});
|
||||
});
|
||||
const setMessageCount = async (component, count: number) =>
|
||||
const setMessageCount = async (component: ReactWrapper, count: number) =>
|
||||
act(async () => {
|
||||
getMessageCountInput(component).simulate("change", { target: { value: count } });
|
||||
component.setProps({});
|
||||
});
|
||||
|
||||
const setSizeLimit = async (component, limit: number) =>
|
||||
const setSizeLimit = async (component: ReactWrapper, limit: number) =>
|
||||
act(async () => {
|
||||
getSizeInput(component).simulate("change", { target: { value: limit } });
|
||||
component.setProps({});
|
||||
});
|
||||
|
||||
const setIncludeAttachments = async (component, checked) =>
|
||||
const setIncludeAttachments = async (component: ReactWrapper, checked: boolean) =>
|
||||
act(async () => {
|
||||
getAttachmentsCheckbox(component).simulate("change", { target: { checked } });
|
||||
component.setProps({});
|
||||
|
|
|
@ -125,8 +125,8 @@ describe("ForwardDialog", () => {
|
|||
const { container } = mountForwardDialog();
|
||||
|
||||
// Make sendEvent require manual resolution so we can see the sending state
|
||||
let finishSend;
|
||||
let cancelSend;
|
||||
let finishSend: (arg?: any) => void;
|
||||
let cancelSend: () => void;
|
||||
mockClient.sendEvent.mockImplementation(
|
||||
<T extends {}>() =>
|
||||
new Promise<T>((resolve, reject) => {
|
||||
|
@ -135,8 +135,8 @@ describe("ForwardDialog", () => {
|
|||
}),
|
||||
);
|
||||
|
||||
let firstButton;
|
||||
let secondButton;
|
||||
let firstButton: Element;
|
||||
let secondButton: Element;
|
||||
const update = () => {
|
||||
[firstButton, secondButton] = container.querySelectorAll(".mx_ForwardList_sendButton");
|
||||
};
|
||||
|
@ -253,7 +253,7 @@ describe("ForwardDialog", () => {
|
|||
[M_ASSET.name]: { type: LocationAssetType.Pin },
|
||||
[M_LOCATION.name]: {
|
||||
uri: geoUri,
|
||||
description: undefined,
|
||||
description: undefined as string,
|
||||
},
|
||||
};
|
||||
expect(mockClient.sendEvent).toHaveBeenCalledWith(
|
||||
|
@ -280,7 +280,7 @@ describe("ForwardDialog", () => {
|
|||
[M_ASSET.name]: { type: LocationAssetType.Pin },
|
||||
[M_LOCATION.name]: {
|
||||
uri: geoUri,
|
||||
description: undefined,
|
||||
description: undefined as string,
|
||||
},
|
||||
};
|
||||
expect(mockClient.sendEvent).toHaveBeenCalledWith(
|
||||
|
@ -301,7 +301,7 @@ describe("ForwardDialog", () => {
|
|||
[M_ASSET.name]: { type: LocationAssetType.Pin },
|
||||
[M_LOCATION.name]: {
|
||||
uri: geoUri,
|
||||
description: undefined,
|
||||
description: undefined as string,
|
||||
},
|
||||
geo_uri: geoUri,
|
||||
[M_TIMESTAMP.name]: timestamp,
|
||||
|
|
|
@ -73,8 +73,9 @@ describe("<UserSettingsDialog />", () => {
|
|||
mockSdkConfig.get.mockReturnValue({ brand: "Test" });
|
||||
});
|
||||
|
||||
const getActiveTabLabel = (container) => container.querySelector(".mx_TabbedView_tabLabel_active").textContent;
|
||||
const getActiveTabHeading = (container) => container.querySelector(".mx_SettingsTab_heading").textContent;
|
||||
const getActiveTabLabel = (container: Element) =>
|
||||
container.querySelector(".mx_TabbedView_tabLabel_active").textContent;
|
||||
const getActiveTabHeading = (container: Element) => container.querySelector(".mx_SettingsTab_heading").textContent;
|
||||
|
||||
it("should render general settings tab when no initialTabId", () => {
|
||||
const { container } = render(getComponent());
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import React, { ComponentProps } from "react";
|
||||
// eslint-disable-next-line deprecate/import
|
||||
import { mount, ReactWrapper } from "enzyme";
|
||||
import { MatrixEvent, RoomMember } from "matrix-js-sdk/src/matrix";
|
||||
|
@ -60,7 +60,7 @@ describe("EventListSummary", function () {
|
|||
*/
|
||||
interface MembershipEventParams {
|
||||
senderId?: string;
|
||||
userId: string;
|
||||
userId?: string;
|
||||
membership: string;
|
||||
prevMembership?: string;
|
||||
}
|
||||
|
@ -100,11 +100,11 @@ describe("EventListSummary", function () {
|
|||
// Generate the same sequence of `events` for `n` users, where each user ID
|
||||
// is created by replacing the first "$" in userIdTemplate with `i` for
|
||||
// `i = 0 .. n`.
|
||||
const generateEventsForUsers = (userIdTemplate, n, events) => {
|
||||
const generateEventsForUsers = (userIdTemplate: string, n: number, events: MembershipEventParams[]) => {
|
||||
let eventsForUsers: MatrixEvent[] = [];
|
||||
let userId = "";
|
||||
for (let i = 0; i < n; i++) {
|
||||
userId = userIdTemplate.replace("$", i);
|
||||
userId = userIdTemplate.replace("$", String(i));
|
||||
events.forEach((e) => {
|
||||
e.userId = userId;
|
||||
});
|
||||
|
@ -117,7 +117,7 @@ describe("EventListSummary", function () {
|
|||
...mockClientMethodsUser(),
|
||||
});
|
||||
|
||||
const defaultProps = {
|
||||
const defaultProps: ComponentProps<typeof EventListSummary> = {
|
||||
layout: Layout.Bubble,
|
||||
events: [],
|
||||
children: [],
|
||||
|
|
|
@ -15,7 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React from "react";
|
||||
import { fireEvent, render } from "@testing-library/react";
|
||||
import { fireEvent, render, RenderResult } from "@testing-library/react";
|
||||
|
||||
import StyledRadioGroup from "../../../../src/components/views/elements/StyledRadioGroup";
|
||||
|
||||
|
@ -44,8 +44,10 @@ describe("<StyledRadioGroup />", () => {
|
|||
};
|
||||
const getComponent = (props = {}) => render(<StyledRadioGroup {...defaultProps} {...props} />);
|
||||
|
||||
const getInputByValue = (component, value) => component.container.querySelector(`input[value="${value}"]`);
|
||||
const getCheckedInput = (component) => component.container.querySelector("input[checked]");
|
||||
const getInputByValue = (component: RenderResult, value: string) =>
|
||||
component.container.querySelector<HTMLInputElement>(`input[value="${value}"]`);
|
||||
const getCheckedInput = (component: RenderResult) =>
|
||||
component.container.querySelector<HTMLInputElement>("input[checked]");
|
||||
|
||||
it("renders radios correctly when no value is provided", () => {
|
||||
const component = getComponent();
|
||||
|
|
|
@ -61,7 +61,7 @@ describe("<TooltipTarget />", () => {
|
|||
});
|
||||
|
||||
const alignmentKeys = Object.keys(Alignment).filter((o: any) => isNaN(o));
|
||||
it.each(alignmentKeys)("displays %s aligned tooltip on mouseover", async (alignment) => {
|
||||
it.each(alignmentKeys)("displays %s aligned tooltip on mouseover", async (alignment: any) => {
|
||||
const wrapper = getComponent({ alignment: Alignment[alignment] });
|
||||
act(() => {
|
||||
Simulate.mouseOver(wrapper);
|
||||
|
|
|
@ -16,7 +16,7 @@ limitations under the License.
|
|||
|
||||
import React from "react";
|
||||
// eslint-disable-next-line deprecate/import
|
||||
import { mount } from "enzyme";
|
||||
import { mount, ReactWrapper } from "enzyme";
|
||||
import { act } from "react-dom/test-utils";
|
||||
|
||||
import LiveDurationDropdown, {
|
||||
|
@ -33,9 +33,9 @@ describe("<LiveDurationDropdown />", () => {
|
|||
};
|
||||
const getComponent = (props = {}) => mount(<LiveDurationDropdown {...defaultProps} {...props} />);
|
||||
|
||||
const getOption = (wrapper, timeout) => findById(wrapper, `live-duration__${timeout}`).at(0);
|
||||
const getSelectedOption = (wrapper) => findById(wrapper, "live-duration_value");
|
||||
const openDropdown = (wrapper) =>
|
||||
const getOption = (wrapper: ReactWrapper, timeout: number) => findById(wrapper, `live-duration__${timeout}`).at(0);
|
||||
const getSelectedOption = (wrapper: ReactWrapper) => findById(wrapper, "live-duration_value");
|
||||
const openDropdown = (wrapper: ReactWrapper) =>
|
||||
act(() => {
|
||||
wrapper.find('[role="button"]').at(0).simulate("click");
|
||||
wrapper.setProps({});
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
import React from "react";
|
||||
import * as maplibregl from "maplibre-gl";
|
||||
// eslint-disable-next-line deprecate/import
|
||||
import { mount } from "enzyme";
|
||||
import { mount, ReactWrapper } from "enzyme";
|
||||
import { act } from "react-dom/test-utils";
|
||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||
|
@ -239,11 +239,12 @@ describe("LocationPicker", () => {
|
|||
const shareType = LocationShareType.Live;
|
||||
testUserLocationShareTypes(shareType);
|
||||
|
||||
const getOption = (wrapper, timeout) => findById(wrapper, `live-duration__${timeout}`).at(0);
|
||||
const getDropdown = (wrapper) => findByTestId(wrapper, "live-duration-dropdown");
|
||||
const getSelectedOption = (wrapper) => findById(wrapper, "live-duration_value");
|
||||
const getOption = (wrapper: ReactWrapper, timeout: number) =>
|
||||
findById(wrapper, `live-duration__${timeout}`).at(0);
|
||||
const getDropdown = (wrapper: ReactWrapper) => findByTestId(wrapper, "live-duration-dropdown");
|
||||
const getSelectedOption = (wrapper: ReactWrapper) => findById(wrapper, "live-duration_value");
|
||||
|
||||
const openDropdown = (wrapper) =>
|
||||
const openDropdown = (wrapper: ReactWrapper) =>
|
||||
act(() => {
|
||||
const dropdown = getDropdown(wrapper);
|
||||
dropdown.find('[role="button"]').at(0).simulate("click");
|
||||
|
|
|
@ -52,6 +52,6 @@ describe("<LocationViewDialog />", () => {
|
|||
// @ts-ignore cheat assignment to property
|
||||
selfShareEvent.sender = member;
|
||||
const component = getComponent({ mxEvent: selfShareEvent });
|
||||
expect(component.find("SmartMarker").props()["roomMember"]).toEqual(member);
|
||||
expect(component.find("SmartMarker").prop("roomMember")).toEqual(member);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -40,7 +40,7 @@ describe("DateSeparator", () => {
|
|||
};
|
||||
const RealDate = global.Date;
|
||||
class MockDate extends Date {
|
||||
constructor(date) {
|
||||
constructor(date: string | number | Date) {
|
||||
super(date || now);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import React, { ComponentProps } from "react";
|
||||
// eslint-disable-next-line deprecate/import
|
||||
import { mount } from "enzyme";
|
||||
import { act } from "react-dom/test-utils";
|
||||
|
@ -63,7 +63,7 @@ describe("<MBeaconBody />", () => {
|
|||
|
||||
const defaultEvent = makeBeaconInfoEvent(aliceId, roomId, { isLive: true }, "$alice-room1-1");
|
||||
|
||||
const defaultProps = {
|
||||
const defaultProps: ComponentProps<typeof MBeaconBody> = {
|
||||
mxEvent: defaultEvent,
|
||||
highlights: [],
|
||||
highlightLink: "",
|
||||
|
@ -343,7 +343,7 @@ describe("<MBeaconBody />", () => {
|
|||
|
||||
const redactionEvent = new MatrixEvent({ type: EventType.RoomRedaction, content: { reason: "test reason" } });
|
||||
|
||||
const setupRoomWithBeacon = (beaconInfoEvent, locationEvents: MatrixEvent[] = []) => {
|
||||
const setupRoomWithBeacon = (beaconInfoEvent: MatrixEvent, locationEvents: MatrixEvent[] = []) => {
|
||||
const room = makeRoomWithStateEvents([beaconInfoEvent], { roomId, mockClient });
|
||||
const beaconInstance = room.currentState.beacons.get(getBeaconInfoIdentifier(beaconInfoEvent));
|
||||
beaconInstance.addLocations(locationEvents);
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import React, { ComponentProps } from "react";
|
||||
// eslint-disable-next-line deprecate/import
|
||||
import { mount } from "enzyme";
|
||||
import { LocationAssetType } from "matrix-js-sdk/src/@types/location";
|
||||
|
@ -46,7 +46,7 @@ describe("MLocationBody", () => {
|
|||
isGuest: jest.fn().mockReturnValue(false),
|
||||
});
|
||||
const defaultEvent = makeLocationEvent("geo:51.5076,-0.1276", LocationAssetType.Pin);
|
||||
const defaultProps = {
|
||||
const defaultProps: ComponentProps<typeof MLocationBody> = {
|
||||
mxEvent: defaultEvent,
|
||||
highlights: [],
|
||||
highlightLink: "",
|
||||
|
@ -79,7 +79,7 @@ describe("MLocationBody", () => {
|
|||
});
|
||||
|
||||
describe("with error", () => {
|
||||
let sdkConfigSpy;
|
||||
let sdkConfigSpy: jest.SpyInstance<any>;
|
||||
|
||||
beforeEach(() => {
|
||||
// eat expected errors to keep console clean
|
||||
|
@ -171,7 +171,7 @@ describe("MLocationBody", () => {
|
|||
const component = getComponent({ mxEvent: selfShareEvent });
|
||||
|
||||
// render self locations with user avatars
|
||||
expect(component.find("SmartMarker").at(0).props()["roomMember"]).toEqual(member);
|
||||
expect(component.find("SmartMarker").at(0).prop("roomMember")).toEqual(member);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import { MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||
import React, { ComponentProps } from "react";
|
||||
import { IContent, MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||
import { render, RenderResult } from "@testing-library/react";
|
||||
|
||||
import MatrixClientContext from "../../../../src/contexts/MatrixClientContext";
|
||||
|
@ -43,7 +43,7 @@ describe("MVideoBody", () => {
|
|||
});
|
||||
|
||||
function makeMVideoBody(w: number, h: number): RenderResult {
|
||||
const content = {
|
||||
const content: IContent = {
|
||||
info: {
|
||||
"w": w,
|
||||
"h": h,
|
||||
|
@ -66,7 +66,7 @@ function makeMVideoBody(w: number, h: number): RenderResult {
|
|||
content,
|
||||
});
|
||||
|
||||
const defaultProps = {
|
||||
const defaultProps: ComponentProps<typeof MVideoBody> = {
|
||||
mxEvent: event,
|
||||
highlights: [],
|
||||
highlightLink: "",
|
||||
|
|
|
@ -76,7 +76,7 @@ describe("<MessageActionBar />", () => {
|
|||
});
|
||||
|
||||
const localStorageMock = (() => {
|
||||
let store = {};
|
||||
let store: Record<string, any> = {};
|
||||
return {
|
||||
getItem: jest.fn().mockImplementation((key) => store[key] ?? null),
|
||||
setItem: jest.fn().mockImplementation((key, value) => {
|
||||
|
|
|
@ -15,7 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React from "react";
|
||||
import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { MatrixClient, MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||
import { MockedObject } from "jest-mock";
|
||||
import { render } from "@testing-library/react";
|
||||
|
||||
|
@ -38,9 +38,9 @@ describe("<TextualBody />", () => {
|
|||
beforeEach(() => {
|
||||
defaultMatrixClient = getMockClientWithEventEmitter({
|
||||
getRoom: () => defaultRoom,
|
||||
getAccountData: () => undefined,
|
||||
getAccountData: (): MatrixEvent | undefined => undefined,
|
||||
isGuest: () => false,
|
||||
mxcUrlToHttp: (s) => s,
|
||||
mxcUrlToHttp: (s: string) => s,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -56,7 +56,7 @@ describe("<TextualBody />", () => {
|
|||
});
|
||||
const defaultProps = {
|
||||
mxEvent: defaultEvent,
|
||||
highlights: [],
|
||||
highlights: [] as string[],
|
||||
highlightLink: "",
|
||||
onMessageAllowed: jest.fn(),
|
||||
onHeightChanged: jest.fn(),
|
||||
|
@ -158,17 +158,17 @@ describe("<TextualBody />", () => {
|
|||
});
|
||||
|
||||
describe("renders formatted m.text correctly", () => {
|
||||
let matrixClient;
|
||||
let matrixClient: MatrixClient;
|
||||
beforeEach(() => {
|
||||
matrixClient = getMockClientWithEventEmitter({
|
||||
getRoom: () => mkStubRoom("room_id", "room name", undefined),
|
||||
getAccountData: () => undefined,
|
||||
getAccountData: (): MatrixEvent | undefined => undefined,
|
||||
getUserId: () => "@me:my_server",
|
||||
getHomeserverUrl: () => "https://my_server/",
|
||||
on: () => undefined,
|
||||
removeListener: () => undefined,
|
||||
on: (): void => undefined,
|
||||
removeListener: (): void => undefined,
|
||||
isGuest: () => false,
|
||||
mxcUrlToHttp: (s) => s,
|
||||
mxcUrlToHttp: (s: string) => s,
|
||||
});
|
||||
DMRoomMap.makeShared();
|
||||
});
|
||||
|
@ -375,10 +375,10 @@ describe("<TextualBody />", () => {
|
|||
|
||||
const matrixClient = getMockClientWithEventEmitter({
|
||||
getRoom: () => mkStubRoom("room_id", "room name", undefined),
|
||||
getAccountData: () => undefined,
|
||||
getUrlPreview: (url) => new Promise(() => {}),
|
||||
getAccountData: (): MatrixClient | undefined => undefined,
|
||||
getUrlPreview: (url: string) => new Promise(() => {}),
|
||||
isGuest: () => false,
|
||||
mxcUrlToHttp: (s) => s,
|
||||
mxcUrlToHttp: (s: string) => s,
|
||||
});
|
||||
DMRoomMap.makeShared();
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ describe("<PinnedMessagesCard />", () => {
|
|||
};
|
||||
|
||||
const mountPins = async (room: Room): Promise<ReactWrapper<ComponentProps<typeof PinnedMessagesCard>>> => {
|
||||
let pins;
|
||||
let pins: ReactWrapper<ComponentProps<typeof PinnedMessagesCard>>;
|
||||
await act(async () => {
|
||||
pins = mount(
|
||||
<PinnedMessagesCard
|
||||
|
@ -239,9 +239,9 @@ describe("<PinnedMessagesCard />", () => {
|
|||
|
||||
const answers = (poll.unstableExtensibleEvent as PollStartEvent).answers;
|
||||
const responses = [
|
||||
["@alice:example.org", 0],
|
||||
["@bob:example.org", 0],
|
||||
["@eve:example.org", 1],
|
||||
["@alice:example.org", 0] as [string, number],
|
||||
["@bob:example.org", 0] as [string, number],
|
||||
["@eve:example.org", 1] as [string, number],
|
||||
].map(([user, option], i) =>
|
||||
mkEvent({
|
||||
...PollResponseEvent.from([answers[option as number].id], poll.getId()!).serialize(),
|
||||
|
|
|
@ -15,13 +15,14 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import React, { Component } from "react";
|
||||
import ReactTestUtils from "react-dom/test-utils";
|
||||
import ReactDOM from "react-dom";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||
import { User } from "matrix-js-sdk/src/models/user";
|
||||
import { compare } from "matrix-js-sdk/src/utils";
|
||||
import { MatrixClient, RoomState } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
import * as TestUtils from "../../../test-utils";
|
||||
|
@ -43,15 +44,15 @@ describe("MemberList", () => {
|
|||
return room;
|
||||
}
|
||||
|
||||
let parentDiv = null;
|
||||
let client = null;
|
||||
let root = null;
|
||||
let memberListRoom;
|
||||
let memberList = null;
|
||||
let parentDiv: HTMLDivElement = null;
|
||||
let client: MatrixClient = null;
|
||||
let root: Component = null;
|
||||
let memberListRoom: Room;
|
||||
let memberList: MemberList = null;
|
||||
|
||||
let adminUsers = [];
|
||||
let moderatorUsers = [];
|
||||
let defaultUsers = [];
|
||||
let adminUsers: RoomMember[] = [];
|
||||
let moderatorUsers: RoomMember[] = [];
|
||||
let defaultUsers: RoomMember[] = [];
|
||||
|
||||
beforeEach(function () {
|
||||
TestUtils.stubClient();
|
||||
|
@ -109,13 +110,14 @@ describe("MemberList", () => {
|
|||
memberListRoom.currentState = {
|
||||
members: {},
|
||||
getMember: jest.fn(),
|
||||
getStateEvents: (eventType, stateKey) => (stateKey === undefined ? [] : null), // ignore 3pid invites
|
||||
};
|
||||
getStateEvents: ((eventType, stateKey) =>
|
||||
stateKey === undefined ? [] : null) as RoomState["getStateEvents"], // ignore 3pid invites
|
||||
} as unknown as RoomState;
|
||||
for (const member of [...adminUsers, ...moderatorUsers, ...defaultUsers]) {
|
||||
memberListRoom.currentState.members[member.userId] = member;
|
||||
}
|
||||
|
||||
const gatherWrappedRef = (r) => {
|
||||
const gatherWrappedRef = (r: MemberList) => {
|
||||
memberList = r;
|
||||
};
|
||||
const context = new TestSdkContext();
|
||||
|
@ -131,7 +133,7 @@ describe("MemberList", () => {
|
|||
/>
|
||||
</SDKContext.Provider>,
|
||||
parentDiv,
|
||||
);
|
||||
) as unknown as Component;
|
||||
});
|
||||
|
||||
afterEach((done) => {
|
||||
|
@ -144,7 +146,7 @@ describe("MemberList", () => {
|
|||
done();
|
||||
});
|
||||
|
||||
function expectOrderedByPresenceAndPowerLevel(memberTiles, isPresenceEnabled) {
|
||||
function expectOrderedByPresenceAndPowerLevel(memberTiles: MemberTile[], isPresenceEnabled: boolean) {
|
||||
let prevMember = null;
|
||||
for (const tile of memberTiles) {
|
||||
const memberA = prevMember;
|
||||
|
@ -164,8 +166,8 @@ describe("MemberList", () => {
|
|||
let groupChange = false;
|
||||
|
||||
if (isPresenceEnabled) {
|
||||
const convertPresence = (p) => (p === "unavailable" ? "online" : p);
|
||||
const presenceIndex = (p) => {
|
||||
const convertPresence = (p: string) => (p === "unavailable" ? "online" : p);
|
||||
const presenceIndex = (p: string) => {
|
||||
const order = ["active", "online", "offline"];
|
||||
const idx = order.indexOf(convertPresence(p));
|
||||
return idx === -1 ? order.length : idx; // unknown states at the end
|
||||
|
@ -212,7 +214,7 @@ describe("MemberList", () => {
|
|||
}
|
||||
}
|
||||
|
||||
function itDoesOrderMembersCorrectly(enablePresence) {
|
||||
function itDoesOrderMembersCorrectly(enablePresence: boolean) {
|
||||
describe("does order members correctly", () => {
|
||||
// Note: even if presence is disabled, we still expect that the presence
|
||||
// tests will pass. All expectOrderedByPresenceAndPowerLevel does is ensure
|
||||
|
@ -251,7 +253,7 @@ describe("MemberList", () => {
|
|||
// We already have admin, moderator, and default users so leave them alone
|
||||
|
||||
// Bypass all the event listeners and skip to the good part
|
||||
memberList._showPresence = enablePresence;
|
||||
memberList.showPresence = enablePresence;
|
||||
memberList.updateListNow();
|
||||
|
||||
const tiles = ReactTestUtils.scryRenderedComponentsWithType(root, MemberTile);
|
||||
|
|
|
@ -248,13 +248,12 @@ function createRoom(info: IRoomCreationInfo) {
|
|||
}
|
||||
|
||||
function mountHeader(room: Room, propsOverride = {}, roomContext?: Partial<IRoomState>): ReactWrapper {
|
||||
const props = {
|
||||
const props: RoomHeaderProps = {
|
||||
room,
|
||||
inRoom: true,
|
||||
onSearchClick: () => {},
|
||||
onInviteClick: null,
|
||||
onForgetClick: () => {},
|
||||
onCallPlaced: (_type) => {},
|
||||
onAppsClick: () => {},
|
||||
e2eStatus: E2EStatus.Normal,
|
||||
appsShown: true,
|
||||
|
@ -320,7 +319,7 @@ function mkJoinEvent(roomId: string, userId: string) {
|
|||
}
|
||||
|
||||
function mkDirectEvent(roomId: string, userId: string, otherUsers: string[]): MatrixEvent {
|
||||
const content = {};
|
||||
const content: Record<string, string[]> = {};
|
||||
for (const otherUserId of otherUsers) {
|
||||
content[otherUserId] = [roomId];
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import React, { ComponentProps } from "react";
|
||||
import { render, fireEvent, RenderResult, waitFor } from "@testing-library/react";
|
||||
import { Room, RoomMember, MatrixError, IContent } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
|
@ -71,7 +71,7 @@ describe("<RoomPreviewBar />", () => {
|
|||
const inviterUserId = "@inviter:test.com";
|
||||
const otherUserId = "@othertester:test.com";
|
||||
|
||||
const getComponent = (props = {}) => {
|
||||
const getComponent = (props: ComponentProps<typeof RoomPreviewBar> = {}) => {
|
||||
const defaultProps = {
|
||||
room: createRoom(roomId, userId),
|
||||
};
|
||||
|
@ -222,13 +222,13 @@ describe("<RoomPreviewBar />", () => {
|
|||
});
|
||||
describe("without an invited email", () => {
|
||||
describe("for a non-dm room", () => {
|
||||
const mockGetMember = (id) => {
|
||||
const mockGetMember = (id: string) => {
|
||||
if (id === userId) return userMember;
|
||||
return inviterMember;
|
||||
};
|
||||
const onJoinClick = jest.fn();
|
||||
const onRejectClick = jest.fn();
|
||||
let room;
|
||||
let room: Room;
|
||||
|
||||
beforeEach(() => {
|
||||
room = createRoom(roomId, userId);
|
||||
|
@ -282,13 +282,13 @@ describe("<RoomPreviewBar />", () => {
|
|||
});
|
||||
|
||||
describe("for a dm room", () => {
|
||||
const mockGetMember = (id) => {
|
||||
const mockGetMember = (id: string) => {
|
||||
if (id === userId) return userMemberWithDmInvite;
|
||||
return inviterMember;
|
||||
};
|
||||
const onJoinClick = jest.fn();
|
||||
const onRejectClick = jest.fn();
|
||||
let room;
|
||||
let room: Room;
|
||||
|
||||
beforeEach(() => {
|
||||
room = createRoom(roomId, userId);
|
||||
|
@ -324,7 +324,7 @@ describe("<RoomPreviewBar />", () => {
|
|||
{ medium: "not-email", address: "address 2" },
|
||||
];
|
||||
|
||||
const testJoinButton = (props) => async () => {
|
||||
const testJoinButton = (props: ComponentProps<typeof RoomPreviewBar>) => async () => {
|
||||
const onJoinClick = jest.fn();
|
||||
const onRejectClick = jest.fn();
|
||||
const component = getComponent({ ...props, onJoinClick, onRejectClick });
|
||||
|
|
|
@ -24,8 +24,8 @@ import * as mockKeyboard from "../../../../../../src/Keyboard";
|
|||
|
||||
describe("PlainTextComposer", () => {
|
||||
const customRender = (
|
||||
onChange = (_content: string) => void 0,
|
||||
onSend = () => void 0,
|
||||
onChange = (_content: string): void => void 0,
|
||||
onSend = (): void => void 0,
|
||||
disabled = false,
|
||||
initialContent?: string,
|
||||
) => {
|
||||
|
|
|
@ -21,7 +21,7 @@ import { Key } from "../../../../src/Keyboard";
|
|||
import { mockPlatformPeg, unmockPlatformPeg } from "../../../test-utils/platform";
|
||||
import { KeyboardKey, KeyboardShortcut } from "../../../../src/components/views/settings/KeyboardShortcut";
|
||||
|
||||
const renderKeyboardShortcut = (Component, props?) => {
|
||||
const renderKeyboardShortcut = (Component: React.FunctionComponentFactory<any>, props: Record<string, any>) => {
|
||||
return render(<Component {...props} />).container;
|
||||
};
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import {
|
|||
MatrixEvent,
|
||||
Room,
|
||||
NotificationCountType,
|
||||
PushRuleActionName,
|
||||
} from "matrix-js-sdk/src/matrix";
|
||||
import { IThreepid, ThreepidMedium } from "matrix-js-sdk/src/@types/threepids";
|
||||
import { act } from "react-dom/test-utils";
|
||||
|
@ -38,15 +39,14 @@ jest.mock("matrix-js-sdk/src/logger");
|
|||
// Avoid indirectly importing any eagerly created stores that would require extra setup
|
||||
jest.mock("../../../../src/Notifier");
|
||||
|
||||
const masterRule = {
|
||||
actions: ["dont_notify"],
|
||||
const masterRule: IPushRule = {
|
||||
actions: [PushRuleActionName.DontNotify],
|
||||
conditions: [],
|
||||
default: true,
|
||||
enabled: false,
|
||||
rule_id: RuleId.Master,
|
||||
};
|
||||
// eslint-disable-next-line max-len
|
||||
const oneToOneRule = {
|
||||
const oneToOneRule: IPushRule = {
|
||||
conditions: [
|
||||
{ kind: "room_member_count", is: "2" },
|
||||
{ kind: "event_match", key: "type", pattern: "m.room.message" },
|
||||
|
@ -56,8 +56,7 @@ const oneToOneRule = {
|
|||
default: true,
|
||||
enabled: true,
|
||||
} as IPushRule;
|
||||
// eslint-disable-next-line max-len
|
||||
const encryptedOneToOneRule = {
|
||||
const encryptedOneToOneRule: IPushRule = {
|
||||
conditions: [
|
||||
{ kind: "room_member_count", is: "2" },
|
||||
{ kind: "event_match", key: "type", pattern: "m.room.encrypted" },
|
||||
|
@ -67,15 +66,13 @@ const encryptedOneToOneRule = {
|
|||
default: true,
|
||||
enabled: true,
|
||||
} as IPushRule;
|
||||
// eslint-disable-next-line max-len
|
||||
const encryptedGroupRule = {
|
||||
const encryptedGroupRule: IPushRule = {
|
||||
conditions: [{ kind: "event_match", key: "type", pattern: "m.room.encrypted" }],
|
||||
actions: ["dont_notify"],
|
||||
rule_id: ".m.rule.encrypted",
|
||||
default: true,
|
||||
enabled: true,
|
||||
} as IPushRule;
|
||||
// eslint-disable-next-line max-len
|
||||
const pushRules: IPushRules = {
|
||||
global: {
|
||||
underride: [
|
||||
|
@ -367,7 +364,7 @@ describe("<Notifications />", () => {
|
|||
|
||||
it("toggles and sets settings correctly", async () => {
|
||||
await getComponentAndWait();
|
||||
let audioNotifsToggle;
|
||||
let audioNotifsToggle: HTMLDivElement;
|
||||
|
||||
const update = () => {
|
||||
audioNotifsToggle = screen
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import React, { ComponentProps } from "react";
|
||||
import { fireEvent, render } from "@testing-library/react";
|
||||
import { PUSHER_ENABLED } from "matrix-js-sdk/src/@types/event";
|
||||
|
||||
|
@ -28,11 +28,10 @@ describe("<DeviceDetails />", () => {
|
|||
isVerified: false,
|
||||
deviceType: DeviceType.Unknown,
|
||||
};
|
||||
const defaultProps = {
|
||||
const defaultProps: ComponentProps<typeof DeviceDetails> = {
|
||||
device: baseDevice,
|
||||
pusher: null,
|
||||
isSigningOut: false,
|
||||
isLoading: false,
|
||||
onSignOutDevice: jest.fn(),
|
||||
saveDeviceName: jest.fn(),
|
||||
setPushNotifications: jest.fn(),
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import React, { ComponentProps } from "react";
|
||||
import { act, fireEvent, render } from "@testing-library/react";
|
||||
|
||||
import { FilteredDeviceList } from "../../../../../src/components/views/settings/devices/FilteredDeviceList";
|
||||
|
@ -59,13 +59,12 @@ describe("<FilteredDeviceList />", () => {
|
|||
last_seen_ts: Date.now() - MS_DAY * 100,
|
||||
deviceType: DeviceType.Unknown,
|
||||
};
|
||||
const defaultProps = {
|
||||
const defaultProps: ComponentProps<typeof FilteredDeviceList> = {
|
||||
onFilterChange: jest.fn(),
|
||||
onDeviceExpandToggle: jest.fn(),
|
||||
onSignOutDevices: jest.fn(),
|
||||
saveDeviceName: jest.fn(),
|
||||
setPushNotifications: jest.fn(),
|
||||
setPusherEnabled: jest.fn(),
|
||||
setSelectedDeviceIds: jest.fn(),
|
||||
localNotificationSettings: new Map(),
|
||||
expandedDeviceIds: [],
|
||||
|
|
|
@ -28,7 +28,7 @@ jest.mock("matrix-js-sdk/src/rendezvous/channels");
|
|||
|
||||
const mockedFlow = jest.fn();
|
||||
|
||||
jest.mock("../../../../../src/components/views/auth/LoginWithQRFlow", () => (props) => {
|
||||
jest.mock("../../../../../src/components/views/auth/LoginWithQRFlow", () => (props: Record<string, any>) => {
|
||||
mockedFlow(props);
|
||||
return <div />;
|
||||
});
|
||||
|
|
|
@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { UIAFlow } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { deleteDevicesWithInteractiveAuth } from "../../../../../src/components/views/settings/devices/deleteDevices";
|
||||
import Modal from "../../../../../src/Modal";
|
||||
import { getMockClientWithEventEmitter, mockClientMethodsUser } from "../../../../test-utils";
|
||||
|
@ -28,7 +30,7 @@ describe("deleteDevices()", () => {
|
|||
|
||||
const modalSpy = jest.spyOn(Modal, "createDialog");
|
||||
|
||||
const interactiveAuthError = { httpStatus: 401, data: { flows: [] } };
|
||||
const interactiveAuthError = { httpStatus: 401, data: { flows: [] as UIAFlow[] } };
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
|
|
|
@ -46,7 +46,7 @@ describe("RolesRoomSettingsTab", () => {
|
|||
});
|
||||
|
||||
describe("Element Call", () => {
|
||||
const mockPowerLevels = (events): void => {
|
||||
const mockPowerLevels = (events: Record<string, number>): void => {
|
||||
jest.spyOn(room.currentState, "getStateEvents").mockReturnValue({
|
||||
getContent: () => ({
|
||||
events,
|
||||
|
|
|
@ -24,7 +24,7 @@ import { mockPlatformPeg } from "../../../../../test-utils/platform";
|
|||
const PATH_TO_KEYBOARD_SHORTCUTS = "../../../../../../src/accessibility/KeyboardShortcuts";
|
||||
const PATH_TO_KEYBOARD_SHORTCUT_UTILS = "../../../../../../src/accessibility/KeyboardShortcutUtils";
|
||||
|
||||
const mockKeyboardShortcuts = (override) => {
|
||||
const mockKeyboardShortcuts = (override: Record<string, any>) => {
|
||||
jest.doMock(PATH_TO_KEYBOARD_SHORTCUTS, () => {
|
||||
const original = jest.requireActual(PATH_TO_KEYBOARD_SHORTCUTS);
|
||||
return {
|
||||
|
@ -34,7 +34,7 @@ const mockKeyboardShortcuts = (override) => {
|
|||
});
|
||||
};
|
||||
|
||||
const mockKeyboardShortcutUtils = (override) => {
|
||||
const mockKeyboardShortcutUtils = (override: Record<string, any>) => {
|
||||
jest.doMock(PATH_TO_KEYBOARD_SHORTCUT_UTILS, () => {
|
||||
const original = jest.requireActual(PATH_TO_KEYBOARD_SHORTCUT_UTILS);
|
||||
return {
|
||||
|
@ -68,7 +68,7 @@ describe("KeyboardUserSettingsTab", () => {
|
|||
},
|
||||
});
|
||||
mockKeyboardShortcutUtils({
|
||||
getKeyboardShortcutValue: (name) => {
|
||||
getKeyboardShortcutValue: (name: string) => {
|
||||
switch (name) {
|
||||
case "keybind1":
|
||||
return {
|
||||
|
@ -88,7 +88,7 @@ describe("KeyboardUserSettingsTab", () => {
|
|||
}
|
||||
}
|
||||
},
|
||||
getKeyboardShortcutDisplayName: (name) => {
|
||||
getKeyboardShortcutDisplayName: (name: string) => {
|
||||
switch (name) {
|
||||
case "keybind1":
|
||||
return "Cancel replying to a message";
|
||||
|
|
|
@ -927,7 +927,7 @@ describe("<SessionManagerTab />", () => {
|
|||
// get a handle for resolving the delete call
|
||||
// because promise flushing after the confirm modal is resolving this too
|
||||
// and we want to test the loading state here
|
||||
let resolveDeleteRequest;
|
||||
let resolveDeleteRequest: (v?: IAuthData) => void;
|
||||
mockClient.deleteMultipleDevices.mockImplementation(() => {
|
||||
const promise = new Promise<IAuthData>((resolve) => {
|
||||
resolveDeleteRequest = resolve;
|
||||
|
|
|
@ -21,7 +21,7 @@ import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
|||
|
||||
import UnwrappedSpacePanel from "../../../../src/components/views/spaces/SpacePanel";
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
import { SpaceKey } from "../../../../src/stores/spaces";
|
||||
import { MetaSpace, SpaceKey } from "../../../../src/stores/spaces";
|
||||
import { shouldShowComponent } from "../../../../src/customisations/helpers/UIComponents";
|
||||
import { UIComponent } from "../../../../src/settings/UIFeature";
|
||||
import { wrapInSdkContext } from "../../../test-utils";
|
||||
|
@ -31,9 +31,9 @@ jest.mock("../../../../src/stores/spaces/SpaceStore", () => {
|
|||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const EventEmitter = require("events");
|
||||
class MockSpaceStore extends EventEmitter {
|
||||
invitedSpaces = [];
|
||||
enabledMetaSpaces = [];
|
||||
spacePanelSpaces = [];
|
||||
invitedSpaces: SpaceKey[] = [];
|
||||
enabledMetaSpaces: MetaSpace[] = [];
|
||||
spacePanelSpaces: string[] = [];
|
||||
activeSpace: SpaceKey = "!space1";
|
||||
}
|
||||
return {
|
||||
|
|
|
@ -93,15 +93,15 @@ describe("<SpaceSettingsVisibilityTab />", () => {
|
|||
};
|
||||
|
||||
const getByTestId = (container: Element, id: string) => container.querySelector(`[data-test-id=${id}]`);
|
||||
const toggleGuestAccessSection = async (component) => {
|
||||
const toggleGuestAccessSection = async (component: Element) => {
|
||||
const toggleButton = getByTestId(component, "toggle-guest-access-btn");
|
||||
await act(async () => {
|
||||
Simulate.click(toggleButton);
|
||||
});
|
||||
};
|
||||
const getGuestAccessToggle = (component) => component.querySelector('[aria-label="Enable guest access"');
|
||||
const getHistoryVisibilityToggle = (component) => component.querySelector('[aria-label="Preview Space"');
|
||||
const getErrorMessage = (component) => getByTestId(component, "space-settings-error")?.textContent;
|
||||
const getGuestAccessToggle = (component: Element) => component.querySelector('[aria-label="Enable guest access"');
|
||||
const getHistoryVisibilityToggle = (component: Element) => component.querySelector('[aria-label="Preview Space"');
|
||||
const getErrorMessage = (component: Element) => getByTestId(component, "space-settings-error")?.textContent;
|
||||
|
||||
beforeEach(() => {
|
||||
(mockMatrixClient.sendStateEvent as jest.Mock).mockClear().mockResolvedValue({});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue