Migrate to stylistic
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
d8052e6a73
commit
6c6bf811a6
124 changed files with 239 additions and 196 deletions
|
@ -35,6 +35,7 @@ beforeEach(() => {
|
|||
//
|
||||
// These are also require() calls to make sure they get called
|
||||
// synchronously.
|
||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||
require("./setup/setupManualMocks"); // must be first
|
||||
require("./setup/setupLanguage");
|
||||
require("./setup/setupConfig");
|
||||
|
|
|
@ -669,7 +669,7 @@ export function mkServerConfig(
|
|||
// These methods make some use of some private methods on the AsyncStoreWithClient to simplify getting into a consistent
|
||||
// ready state without needing to wire up a dispatcher and pretend to be a js-sdk client.
|
||||
|
||||
export const setupAsyncStoreWithClient = async <T extends Object = any>(
|
||||
export const setupAsyncStoreWithClient = async <T extends object = any>(
|
||||
store: AsyncStoreWithClient<T>,
|
||||
client: MatrixClient,
|
||||
) => {
|
||||
|
@ -679,7 +679,7 @@ export const setupAsyncStoreWithClient = async <T extends Object = any>(
|
|||
await store.onReady();
|
||||
};
|
||||
|
||||
export const resetAsyncStoreWithClient = async <T extends Object = any>(store: AsyncStoreWithClient<T>) => {
|
||||
export const resetAsyncStoreWithClient = async <T extends object = any>(store: AsyncStoreWithClient<T>) => {
|
||||
// @ts-ignore protected access
|
||||
await store.onNotReady();
|
||||
};
|
||||
|
|
|
@ -86,7 +86,6 @@ describe("Terms", function () {
|
|||
policy_the_first: POLICY_ONE,
|
||||
},
|
||||
});
|
||||
mockClient.agreeToTerms;
|
||||
|
||||
const interactionCallback = jest.fn();
|
||||
await startTermsFlow(mockClient, [IM_SERVICE_ONE], interactionCallback);
|
||||
|
|
|
@ -18,7 +18,7 @@ import dispatcher from "../../../../../src/dispatcher/dispatcher";
|
|||
import { Action } from "../../../../../src/dispatcher/actions";
|
||||
|
||||
jest.mock("../../../../../src/stores/OwnBeaconStore", () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const EventEmitter = require("events");
|
||||
class MockOwnBeaconStore extends EventEmitter {
|
||||
public getLiveBeaconIdsWithLocationPublishError = jest.fn().mockReturnValue([]);
|
||||
|
|
|
@ -15,7 +15,6 @@ import { makePollStartEvent, mockIntlDateTimeFormat, unmockIntlDateTimeFormat }
|
|||
|
||||
describe("<PollListItem />", () => {
|
||||
const event = makePollStartEvent("Question?", "@me:domain.org");
|
||||
event.getContent().origin;
|
||||
const defaultProps = { event, onClick: jest.fn() };
|
||||
const getComponent = (props = {}) => render(<PollListItem {...defaultProps} {...props} />);
|
||||
|
||||
|
|
|
@ -247,11 +247,11 @@ describe("MessageComposer", () => {
|
|||
});
|
||||
|
||||
describe("UIStore interactions", () => {
|
||||
let resizeCallback: Function;
|
||||
let resizeCallback: (key: string, data: object) => void;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.spyOn(UIStore.instance, "on").mockImplementation(
|
||||
(_event: string | symbol, listener: Function): any => {
|
||||
(_event: string | symbol, listener: (key: string, data: object) => void): any => {
|
||||
resizeCallback = listener;
|
||||
},
|
||||
);
|
||||
|
|
|
@ -564,7 +564,7 @@ describe("RoomHeader", () => {
|
|||
|
||||
jest.spyOn(SdkContextClass.instance.roomViewStore, "isViewingCall").mockReturnValue(true);
|
||||
|
||||
render(<RoomHeader room={room} />, getWrapper()).container;
|
||||
render(<RoomHeader room={room} />, getWrapper());
|
||||
|
||||
expect(getByLabelText(document.body, _t("voip|get_call_link"))).toBeInTheDocument();
|
||||
});
|
||||
|
|
|
@ -210,7 +210,6 @@ describe("RoomList", () => {
|
|||
beforeEach(async () => {
|
||||
cleanup();
|
||||
const rooms: Room[] = [];
|
||||
RoomListStore.instance;
|
||||
testUtils.mkRoom(client, videoRoomPrivate, rooms);
|
||||
testUtils.mkRoom(client, videoRoomPublic, rooms);
|
||||
testUtils.mkRoom(client, videoRoomKnock, rooms);
|
||||
|
|
|
@ -100,7 +100,7 @@ describe("<RoomPreviewBar />", () => {
|
|||
|
||||
afterEach(() => {
|
||||
const container = document.body.firstChild;
|
||||
container && document.body.removeChild(container);
|
||||
if (container) document.body.removeChild(container);
|
||||
});
|
||||
|
||||
it("renders joining message", () => {
|
||||
|
|
|
@ -85,7 +85,7 @@ const drop = async (element: HTMLElement) => {
|
|||
};
|
||||
|
||||
jest.mock("../../../../../src/stores/spaces/SpaceStore", () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const EventEmitter = require("events");
|
||||
class MockSpaceStore extends EventEmitter {
|
||||
invitedSpaces: SpaceKey[] = [];
|
||||
|
|
|
@ -21,7 +21,7 @@ import { StaticNotificationState } from "../../../../../src/stores/notifications
|
|||
import { NotificationLevel } from "../../../../../src/stores/notifications/NotificationLevel";
|
||||
|
||||
jest.mock("../../../../../src/stores/spaces/SpaceStore", () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const EventEmitter = require("events");
|
||||
class MockSpaceStore extends EventEmitter {
|
||||
activeSpace: SpaceKey = "!space1";
|
||||
|
|
|
@ -40,15 +40,11 @@ describe("SdkContextClass", () => {
|
|||
});
|
||||
|
||||
it("userProfilesStore should raise an error without a client", () => {
|
||||
expect(() => {
|
||||
sdkContext.userProfilesStore;
|
||||
}).toThrow("Unable to create UserProfilesStore without a client");
|
||||
expect(() => sdkContext.userProfilesStore).toThrow("Unable to create UserProfilesStore without a client");
|
||||
});
|
||||
|
||||
it("oidcClientStore should raise an error without a client", () => {
|
||||
expect(() => {
|
||||
sdkContext.oidcClientStore;
|
||||
}).toThrow("Unable to create OidcClientStore without a client");
|
||||
expect(() => sdkContext.oidcClientStore).toThrow("Unable to create OidcClientStore without a client");
|
||||
});
|
||||
|
||||
describe("when SDKContext has a client", () => {
|
||||
|
|
|
@ -358,12 +358,12 @@ describe("JitsiCall", () => {
|
|||
new CustomEvent("widgetapirequest", { detail: {} }),
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(callback).toHaveBeenNthCalledWith(1, ConnectionState.Disconnected, ConnectionState.Connected),
|
||||
expect(callback).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
ConnectionState.WidgetLoading,
|
||||
ConnectionState.Disconnected,
|
||||
);
|
||||
expect(callback).toHaveBeenNthCalledWith(1, ConnectionState.Disconnected, ConnectionState.Connected);
|
||||
expect(callback).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
ConnectionState.WidgetLoading,
|
||||
ConnectionState.Disconnected,
|
||||
);
|
||||
expect(callback).toHaveBeenNthCalledWith(3, ConnectionState.Connecting, ConnectionState.WidgetLoading);
|
||||
});
|
||||
// in video rooms we expect the call to immediately reconnect
|
||||
|
|
|
@ -49,7 +49,7 @@ describe("BreadcrumbsStore", () => {
|
|||
|
||||
it("passes through the dynamic room precessors flag", () => {
|
||||
mocked(client.getVisibleRooms).mockReturnValue(fakeRooms(25));
|
||||
store.meetsRoomRequirement;
|
||||
expect(store.meetsRoomRequirement).toBeTruthy();
|
||||
expect(client.getVisibleRooms).toHaveBeenCalledWith(true);
|
||||
});
|
||||
});
|
||||
|
@ -57,7 +57,7 @@ describe("BreadcrumbsStore", () => {
|
|||
describe("And the feature_dynamic_room_predecessors is not enabled", () => {
|
||||
it("passes through the dynamic room precessors flag", () => {
|
||||
mocked(client.getVisibleRooms).mockReturnValue(fakeRooms(25));
|
||||
store.meetsRoomRequirement;
|
||||
expect(store.meetsRoomRequirement).toBeTruthy();
|
||||
expect(client.getVisibleRooms).toHaveBeenCalledWith(false);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -70,7 +70,7 @@ describe("OwnProfileStore", () => {
|
|||
);
|
||||
try {
|
||||
await ownProfileStore.start();
|
||||
} catch (ignore) {}
|
||||
} catch {}
|
||||
|
||||
expect(onUpdate).not.toHaveBeenCalled();
|
||||
expect(ownProfileStore.displayName).toBe(client.getSafeUserId());
|
||||
|
|
|
@ -465,7 +465,7 @@ describe("RoomViewStore", function () {
|
|||
try {
|
||||
expect(setRoomVisible.mock.calls[i][0]).toEqual(v[0]);
|
||||
expect(setRoomVisible.mock.calls[i][1]).toEqual(v[1]);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
throw new Error(`i=${i} got ${setRoomVisible.mock.calls[i]} want ${v}`);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -353,7 +353,6 @@ describe("RoomListStore", () => {
|
|||
const videoRoomKnock = "!videoRoomKnock_server";
|
||||
|
||||
const rooms: Room[] = [];
|
||||
RoomListStore.instance;
|
||||
mkRoom(client, videoRoomPrivate, rooms);
|
||||
mkRoom(client, videoRoomPublic, rooms);
|
||||
mkRoom(client, videoRoomKnock, rooms);
|
||||
|
|
|
@ -17,7 +17,7 @@ import SpaceStore from "../../../../../src/stores/spaces/SpaceStore";
|
|||
|
||||
jest.mock("../../../../../src/settings/SettingsStore");
|
||||
jest.mock("../../../../../src/stores/spaces/SpaceStore", () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const EventEmitter = require("events");
|
||||
class MockSpaceStore extends EventEmitter {
|
||||
isRoomInSpace = jest.fn();
|
||||
|
|
|
@ -74,6 +74,7 @@ describe("MegolmExportEncryption", function () {
|
|||
subtle: webCrypto.subtle,
|
||||
},
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
MegolmExportEncryption = require("../../../src/utils/MegolmExportEncryption");
|
||||
});
|
||||
|
||||
|
|
|
@ -218,7 +218,9 @@ describe("SessionLock", () => {
|
|||
const window2 = createWindow();
|
||||
|
||||
// import the dependencies of getSessionLock into the new context
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
window2._uuid = require("uuid");
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
window2._logger = require("matrix-js-sdk/src/logger");
|
||||
window2.SESSION_LOCK_CONSTANTS = SESSION_LOCK_CONSTANTS;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ describe("Singleflight", () => {
|
|||
});
|
||||
|
||||
it("should throw for bad context variables", () => {
|
||||
const permutations: [Object | null, string | null][] = [
|
||||
const permutations: [object | null, string | null][] = [
|
||||
[null, null],
|
||||
[{}, null],
|
||||
[null, "test"],
|
||||
|
|
|
@ -47,7 +47,9 @@ describe("ElectronPlatform", () => {
|
|||
setupLanguageMock();
|
||||
});
|
||||
|
||||
const getElectronEventHandlerCall = (eventType: string): [type: string, handler: Function] | undefined =>
|
||||
const getElectronEventHandlerCall = (
|
||||
eventType: string,
|
||||
): [type: string, handler: (...args: any) => void] | undefined =>
|
||||
mockElectron.on.mock.calls.find(([type]) => type === eventType);
|
||||
|
||||
it("flushes rageshake before quitting", () => {
|
||||
|
|
|
@ -162,7 +162,11 @@ describe("VoiceBroadcastPlayback", () => {
|
|||
jest.spyOn(playback, "removeAllListeners");
|
||||
jest.spyOn(playback, "destroy");
|
||||
playback.on(VoiceBroadcastPlaybackEvent.StateChanged, onStateChanged);
|
||||
fakeTimers ? await flushPromisesWithFakeTimers() : await flushPromises();
|
||||
if (fakeTimers) {
|
||||
await flushPromisesWithFakeTimers();
|
||||
} else {
|
||||
await flushPromises();
|
||||
}
|
||||
return playback;
|
||||
};
|
||||
|
||||
|
|
|
@ -453,7 +453,7 @@ describe("VoiceBroadcastRecording", () => {
|
|||
describe.each([
|
||||
["pause", async () => voiceBroadcastRecording.pause()],
|
||||
["toggle", async () => voiceBroadcastRecording.toggle()],
|
||||
])("and calling %s", (_case: string, action: Function) => {
|
||||
])("and calling %s", (_case: string, action: () => Promise<void>) => {
|
||||
beforeEach(async () => {
|
||||
await action();
|
||||
});
|
||||
|
@ -480,7 +480,7 @@ describe("VoiceBroadcastRecording", () => {
|
|||
describe.each([
|
||||
["pause", async () => voiceBroadcastRecording.pause()],
|
||||
["toggle", async () => voiceBroadcastRecording.toggle()],
|
||||
])("and calling %s", (_case: string, action: Function) => {
|
||||
])("and calling %s", (_case: string, action: () => Promise<void>) => {
|
||||
beforeEach(async () => {
|
||||
await action();
|
||||
});
|
||||
|
@ -590,7 +590,7 @@ describe("VoiceBroadcastRecording", () => {
|
|||
describe.each([
|
||||
["resume", async () => voiceBroadcastRecording.resume()],
|
||||
["toggle", async () => voiceBroadcastRecording.toggle()],
|
||||
])("and calling %s", (_case: string, action: Function) => {
|
||||
])("and calling %s", (_case: string, action: () => Promise<void>) => {
|
||||
beforeEach(async () => {
|
||||
await action();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue