1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-09 08:42:50 +03:00

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 65385 additions and 62478 deletions

View File

@@ -18,15 +18,12 @@ import { MatrixEvent } from "matrix-js-sdk/src/matrix";
import BasePlatform from "../../../src/BasePlatform";
import { IConfigOptions } from "../../../src/IConfigOptions";
import {
getDeviceClientInformation,
recordClientInformation,
} from "../../../src/utils/device/clientInformation";
import { getDeviceClientInformation, recordClientInformation } from "../../../src/utils/device/clientInformation";
import { getMockClientWithEventEmitter } from "../../test-utils";
describe('recordClientInformation()', () => {
const deviceId = 'my-device-id';
const version = '1.2.3';
describe("recordClientInformation()", () => {
const deviceId = "my-device-id";
const version = "1.2.3";
const isElectron = window.electron;
const mockClient = getMockClientWithEventEmitter({
@@ -35,8 +32,8 @@ describe('recordClientInformation()', () => {
});
const sdkConfig: IConfigOptions = {
brand: 'Test Brand',
element_call: { url: '', use_exclusively: false, brand: "Element Call" },
brand: "Test Brand",
element_call: { url: "", use_exclusively: false, brand: "Element Call" },
};
const platform = {
@@ -53,45 +50,31 @@ describe('recordClientInformation()', () => {
window.electron = isElectron;
});
it('saves client information without url for electron clients', async () => {
it("saves client information without url for electron clients", async () => {
window.electron = true;
await recordClientInformation(
mockClient,
sdkConfig,
platform,
);
await recordClientInformation(mockClient, sdkConfig, platform);
expect(mockClient.setAccountData).toHaveBeenCalledWith(
`io.element.matrix_client_information.${deviceId}`,
{
name: sdkConfig.brand,
version,
url: undefined,
},
);
expect(mockClient.setAccountData).toHaveBeenCalledWith(`io.element.matrix_client_information.${deviceId}`, {
name: sdkConfig.brand,
version,
url: undefined,
});
});
it('saves client information with url for non-electron clients', async () => {
await recordClientInformation(
mockClient,
sdkConfig,
platform,
);
it("saves client information with url for non-electron clients", async () => {
await recordClientInformation(mockClient, sdkConfig, platform);
expect(mockClient.setAccountData).toHaveBeenCalledWith(
`io.element.matrix_client_information.${deviceId}`,
{
name: sdkConfig.brand,
version,
url: 'localhost',
},
);
expect(mockClient.setAccountData).toHaveBeenCalledWith(`io.element.matrix_client_information.${deviceId}`, {
name: sdkConfig.brand,
version,
url: "localhost",
});
});
});
describe('getDeviceClientInformation()', () => {
const deviceId = 'my-device-id';
describe("getDeviceClientInformation()", () => {
const deviceId = "my-device-id";
const mockClient = getMockClientWithEventEmitter({
getAccountData: jest.fn(),
@@ -101,19 +84,17 @@ describe('getDeviceClientInformation()', () => {
jest.resetAllMocks();
});
it('returns an empty object when no event exists for the device', () => {
it("returns an empty object when no event exists for the device", () => {
expect(getDeviceClientInformation(mockClient, deviceId)).toEqual({});
expect(mockClient.getAccountData).toHaveBeenCalledWith(
`io.element.matrix_client_information.${deviceId}`,
);
expect(mockClient.getAccountData).toHaveBeenCalledWith(`io.element.matrix_client_information.${deviceId}`);
});
it('returns client information for the device', () => {
it("returns client information for the device", () => {
const eventContent = {
name: 'Element Web',
version: '1.2.3',
url: 'test.com',
name: "Element Web",
version: "1.2.3",
url: "test.com",
};
const event = new MatrixEvent({
type: `io.element.matrix_client_information.${deviceId}`,
@@ -123,13 +104,13 @@ describe('getDeviceClientInformation()', () => {
expect(getDeviceClientInformation(mockClient, deviceId)).toEqual(eventContent);
});
it('excludes values with incorrect types', () => {
it("excludes values with incorrect types", () => {
const eventContent = {
extraField: 'hello',
name: 'Element Web',
extraField: "hello",
name: "Element Web",
// wrong format
version: { value: '1.2.3' },
url: 'test.com',
version: { value: "1.2.3" },
url: "test.com",
};
const event = new MatrixEvent({
type: `io.element.matrix_client_information.${deviceId}`,
@@ -143,4 +124,3 @@ describe('getDeviceClientInformation()', () => {
});
});
});