Use mapped types around account data events (#28752)

* Use mapped types around account data events

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2024-12-19 22:53:51 +00:00
committed by GitHub
parent baaed75c4b
commit be181d2c79
25 changed files with 152 additions and 71 deletions

View File

@@ -16,6 +16,7 @@ import {
IContent,
MatrixEvent,
SyncState,
AccountDataEvents,
} from "matrix-js-sdk/src/matrix";
import { waitFor } from "jest-matrix-react";
import { CallMembership, MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc";
@@ -69,7 +70,7 @@ describe("Notifier", () => {
let MockPlatform: MockedObject<BasePlatform>;
let mockClient: MockedObject<MatrixClient>;
let testRoom: Room;
let accountDataEventKey: string;
let accountDataEventKey: keyof AccountDataEvents;
let accountDataStore: Record<string, MatrixEvent | undefined> = {};
let mockSettings: Record<string, boolean> = {};

View File

@@ -338,19 +338,18 @@ describe("<RoomSummaryCard />", () => {
});
it("does not show public room label for a DM", async () => {
mockClient.getAccountData.mockImplementation(
(eventType) =>
({
[EventType.Direct]: new MatrixEvent({
type: EventType.Direct,
content: {
"@bob:sesame.st": ["some-room-id"],
// this room is a DM with ernie
"@ernie:sesame.st": ["some-other-room-id", room.roomId],
},
}),
})[eventType],
);
mockClient.getAccountData.mockImplementation((eventType) => {
if (eventType === EventType.Direct) {
return new MatrixEvent({
type: EventType.Direct,
content: {
"@bob:sesame.st": ["some-room-id"],
// this room is a DM with ernie
"@ernie:sesame.st": ["some-other-room-id", room.roomId],
},
});
}
});
getComponent();
await flushPromises();

View File

@@ -6,7 +6,14 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/
import { MatrixEvent, NotificationCountType, Room, MatrixClient, ReceiptType } from "matrix-js-sdk/src/matrix";
import {
MatrixEvent,
NotificationCountType,
Room,
MatrixClient,
ReceiptType,
AccountDataEvents,
} from "matrix-js-sdk/src/matrix";
import { Mocked, mocked } from "jest-mock";
import {
@@ -32,7 +39,7 @@ jest.mock("../../../src/settings/SettingsStore");
describe("notifications", () => {
let accountDataStore: Record<string, MatrixEvent> = {};
let mockClient: Mocked<MatrixClient>;
let accountDataEventKey: string;
let accountDataEventKey: keyof AccountDataEvents;
beforeEach(() => {
jest.clearAllMocks();