You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-31 13:44:28 +03:00
Apply prettier formatting
This commit is contained in:
@ -95,14 +95,12 @@ describe("StopGapWidget", () => {
|
||||
|
||||
describe(`and receiving a action:${ElementWidgetActions.JoinCall} message`, () => {
|
||||
beforeEach(async () => {
|
||||
messaging.on.mock.calls.find(
|
||||
([event, listener]) => {
|
||||
if (event === `action:${ElementWidgetActions.JoinCall}`) {
|
||||
listener();
|
||||
return true;
|
||||
}
|
||||
},
|
||||
);
|
||||
messaging.on.mock.calls.find(([event, listener]) => {
|
||||
if (event === `action:${ElementWidgetActions.JoinCall}`) {
|
||||
listener();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("should pause the current voice broadcast recording", () => {
|
||||
|
@ -28,18 +28,19 @@ import { stubClient } from "../../test-utils";
|
||||
describe("StopGapWidgetDriver", () => {
|
||||
let client: MockedObject<MatrixClient>;
|
||||
|
||||
const mkDefaultDriver = (): WidgetDriver => new StopGapWidgetDriver(
|
||||
[],
|
||||
new Widget({
|
||||
id: "test",
|
||||
creatorUserId: "@alice:example.org",
|
||||
type: "example",
|
||||
url: "https://example.org",
|
||||
}),
|
||||
WidgetKind.Room,
|
||||
false,
|
||||
"!1:example.org",
|
||||
);
|
||||
const mkDefaultDriver = (): WidgetDriver =>
|
||||
new StopGapWidgetDriver(
|
||||
[],
|
||||
new Widget({
|
||||
id: "test",
|
||||
creatorUserId: "@alice:example.org",
|
||||
type: "example",
|
||||
url: "https://example.org",
|
||||
}),
|
||||
WidgetKind.Room,
|
||||
false,
|
||||
"!1:example.org",
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
@ -107,7 +108,7 @@ describe("StopGapWidgetDriver", () => {
|
||||
},
|
||||
},
|
||||
"@bob:example.org": {
|
||||
"bobDesktop": {
|
||||
bobDesktop: {
|
||||
hello: "bob",
|
||||
},
|
||||
},
|
||||
@ -115,7 +116,9 @@ describe("StopGapWidgetDriver", () => {
|
||||
|
||||
let driver: WidgetDriver;
|
||||
|
||||
beforeEach(() => { driver = mkDefaultDriver(); });
|
||||
beforeEach(() => {
|
||||
driver = mkDefaultDriver();
|
||||
});
|
||||
|
||||
it("sends unencrypted messages", async () => {
|
||||
await driver.sendToDevice("org.example.foo", false, contentMap);
|
||||
@ -140,7 +143,9 @@ describe("StopGapWidgetDriver", () => {
|
||||
describe("getTurnServers", () => {
|
||||
let driver: WidgetDriver;
|
||||
|
||||
beforeEach(() => { driver = mkDefaultDriver(); });
|
||||
beforeEach(() => {
|
||||
driver = mkDefaultDriver();
|
||||
});
|
||||
|
||||
it("stops if VoIP isn't supported", async () => {
|
||||
jest.spyOn(client, "pollingTurnServers", "get").mockReturnValue(false);
|
||||
@ -199,77 +204,72 @@ describe("StopGapWidgetDriver", () => {
|
||||
describe("readEventRelations", () => {
|
||||
let driver: WidgetDriver;
|
||||
|
||||
beforeEach(() => { driver = mkDefaultDriver(); });
|
||||
beforeEach(() => {
|
||||
driver = mkDefaultDriver();
|
||||
});
|
||||
|
||||
it('reads related events from the current room', async () => {
|
||||
jest.spyOn(SdkContextClass.instance.roomViewStore, 'getRoomId').mockReturnValue('!this-room-id');
|
||||
it("reads related events from the current room", async () => {
|
||||
jest.spyOn(SdkContextClass.instance.roomViewStore, "getRoomId").mockReturnValue("!this-room-id");
|
||||
|
||||
client.relations.mockResolvedValue({
|
||||
originalEvent: new MatrixEvent(),
|
||||
events: [],
|
||||
});
|
||||
|
||||
await expect(driver.readEventRelations('$event')).resolves.toEqual({
|
||||
await expect(driver.readEventRelations("$event")).resolves.toEqual({
|
||||
chunk: [],
|
||||
nextBatch: undefined,
|
||||
prevBatch: undefined,
|
||||
});
|
||||
|
||||
expect(client.relations).toBeCalledWith('!this-room-id', '$event', null, null, {});
|
||||
expect(client.relations).toBeCalledWith("!this-room-id", "$event", null, null, {});
|
||||
});
|
||||
|
||||
it('reads related events from a selected room', async () => {
|
||||
it("reads related events from a selected room", async () => {
|
||||
client.relations.mockResolvedValue({
|
||||
originalEvent: new MatrixEvent(),
|
||||
events: [new MatrixEvent(), new MatrixEvent()],
|
||||
nextBatch: 'next-batch-token',
|
||||
nextBatch: "next-batch-token",
|
||||
});
|
||||
|
||||
await expect(driver.readEventRelations('$event', '!room-id')).resolves.toEqual({
|
||||
chunk: [
|
||||
expect.objectContaining({ content: {} }),
|
||||
expect.objectContaining({ content: {} }),
|
||||
],
|
||||
nextBatch: 'next-batch-token',
|
||||
await expect(driver.readEventRelations("$event", "!room-id")).resolves.toEqual({
|
||||
chunk: [expect.objectContaining({ content: {} }), expect.objectContaining({ content: {} })],
|
||||
nextBatch: "next-batch-token",
|
||||
prevBatch: undefined,
|
||||
});
|
||||
|
||||
expect(client.relations).toBeCalledWith('!room-id', '$event', null, null, {});
|
||||
expect(client.relations).toBeCalledWith("!room-id", "$event", null, null, {});
|
||||
});
|
||||
|
||||
it('reads related events with custom parameters', async () => {
|
||||
it("reads related events with custom parameters", async () => {
|
||||
client.relations.mockResolvedValue({
|
||||
originalEvent: new MatrixEvent(),
|
||||
events: [],
|
||||
});
|
||||
|
||||
await expect(driver.readEventRelations(
|
||||
'$event',
|
||||
'!room-id',
|
||||
'm.reference',
|
||||
'm.room.message',
|
||||
'from-token',
|
||||
'to-token',
|
||||
25,
|
||||
'f',
|
||||
)).resolves.toEqual({
|
||||
await expect(
|
||||
driver.readEventRelations(
|
||||
"$event",
|
||||
"!room-id",
|
||||
"m.reference",
|
||||
"m.room.message",
|
||||
"from-token",
|
||||
"to-token",
|
||||
25,
|
||||
"f",
|
||||
),
|
||||
).resolves.toEqual({
|
||||
chunk: [],
|
||||
nextBatch: undefined,
|
||||
prevBatch: undefined,
|
||||
});
|
||||
|
||||
expect(client.relations).toBeCalledWith(
|
||||
'!room-id',
|
||||
'$event',
|
||||
'm.reference',
|
||||
'm.room.message',
|
||||
{
|
||||
limit: 25,
|
||||
from: 'from-token',
|
||||
to: 'to-token',
|
||||
dir: Direction.Forward,
|
||||
},
|
||||
);
|
||||
expect(client.relations).toBeCalledWith("!room-id", "$event", "m.reference", "m.room.message", {
|
||||
limit: 25,
|
||||
from: "from-token",
|
||||
to: "to-token",
|
||||
dir: Direction.Forward,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -45,15 +45,13 @@ describe("WidgetPermissionStore", () => {
|
||||
mocked(SettingsStore.getValue).mockImplementation((setting: string) => {
|
||||
return settings[setting];
|
||||
});
|
||||
mocked(SettingsStore.setValue).mockImplementation((settingName: string,
|
||||
roomId: string | null,
|
||||
level: SettingLevel,
|
||||
value: any,
|
||||
): Promise<void> => {
|
||||
// the store doesn't use any specific level or room ID (room IDs are packed into keys in `value`)
|
||||
settings[settingName] = value;
|
||||
return Promise.resolve();
|
||||
});
|
||||
mocked(SettingsStore.setValue).mockImplementation(
|
||||
(settingName: string, roomId: string | null, level: SettingLevel, value: any): Promise<void> => {
|
||||
// the store doesn't use any specific level or room ID (room IDs are packed into keys in `value`)
|
||||
settings[settingName] = value;
|
||||
return Promise.resolve();
|
||||
},
|
||||
);
|
||||
mockClient = stubClient();
|
||||
const context = new TestSdkContext();
|
||||
context.client = mockClient;
|
||||
@ -63,39 +61,29 @@ describe("WidgetPermissionStore", () => {
|
||||
it("should persist OIDCState.Allowed for a widget", () => {
|
||||
widgetPermissionStore.setOIDCState(w, WidgetKind.Account, null, OIDCState.Allowed);
|
||||
// check it remembered the value
|
||||
expect(
|
||||
widgetPermissionStore.getOIDCState(w, WidgetKind.Account, null),
|
||||
).toEqual(OIDCState.Allowed);
|
||||
expect(widgetPermissionStore.getOIDCState(w, WidgetKind.Account, null)).toEqual(OIDCState.Allowed);
|
||||
});
|
||||
|
||||
it("should persist OIDCState.Denied for a widget", () => {
|
||||
widgetPermissionStore.setOIDCState(w, WidgetKind.Account, null, OIDCState.Denied);
|
||||
// check it remembered the value
|
||||
expect(
|
||||
widgetPermissionStore.getOIDCState(w, WidgetKind.Account, null),
|
||||
).toEqual(OIDCState.Denied);
|
||||
expect(widgetPermissionStore.getOIDCState(w, WidgetKind.Account, null)).toEqual(OIDCState.Denied);
|
||||
});
|
||||
|
||||
it("should update OIDCState for a widget", () => {
|
||||
widgetPermissionStore.setOIDCState(w, WidgetKind.Account, null, OIDCState.Allowed);
|
||||
widgetPermissionStore.setOIDCState(w, WidgetKind.Account, null, OIDCState.Denied);
|
||||
// check it remembered the latest value
|
||||
expect(
|
||||
widgetPermissionStore.getOIDCState(w, WidgetKind.Account, null),
|
||||
).toEqual(OIDCState.Denied);
|
||||
expect(widgetPermissionStore.getOIDCState(w, WidgetKind.Account, null)).toEqual(OIDCState.Denied);
|
||||
});
|
||||
|
||||
it("should scope the location for a widget when setting OIDC state", () => {
|
||||
// allow this widget for this room
|
||||
widgetPermissionStore.setOIDCState(w, WidgetKind.Room, roomId, OIDCState.Allowed);
|
||||
// check it remembered the value
|
||||
expect(
|
||||
widgetPermissionStore.getOIDCState(w, WidgetKind.Room, roomId),
|
||||
).toEqual(OIDCState.Allowed);
|
||||
expect(widgetPermissionStore.getOIDCState(w, WidgetKind.Room, roomId)).toEqual(OIDCState.Allowed);
|
||||
// check this is not the case for the entire account
|
||||
expect(
|
||||
widgetPermissionStore.getOIDCState(w, WidgetKind.Account, roomId),
|
||||
).toEqual(OIDCState.Unknown);
|
||||
expect(widgetPermissionStore.getOIDCState(w, WidgetKind.Account, roomId)).toEqual(OIDCState.Unknown);
|
||||
});
|
||||
it("is created once in SdkContextClass", () => {
|
||||
const context = new SdkContextClass();
|
||||
|
Reference in New Issue
Block a user