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 65384 additions and 62477 deletions
@@ -1,4 +1,3 @@
/*
Copyright 2022 Šimon Brandner <simon.bra.ag@gmail.com>
@@ -18,8 +17,7 @@ limitations under the License.
import { render } from "@testing-library/react";
import React from "react";
import KeyboardUserSettingsTab from
"../../../../../../src/components/views/settings/tabs/user/KeyboardUserSettingsTab";
import KeyboardUserSettingsTab from "../../../../../../src/components/views/settings/tabs/user/KeyboardUserSettingsTab";
import { Key } from "../../../../../../src/Keyboard";
import { mockPlatformPeg } from "../../../../../test-utils/platform";
@@ -58,19 +56,19 @@ describe("KeyboardUserSettingsTab", () => {
it("renders list of keyboard shortcuts", () => {
mockKeyboardShortcuts({
"CATEGORIES": {
"Composer": {
CATEGORIES: {
Composer: {
settingNames: ["keybind1", "keybind2"],
categoryLabel: "Composer",
},
"Navigation": {
Navigation: {
settingNames: ["keybind3"],
categoryLabel: "Navigation",
},
},
});
mockKeyboardShortcutUtils({
"getKeyboardShortcutValue": (name) => {
getKeyboardShortcutValue: (name) => {
switch (name) {
case "keybind1":
return {
@@ -80,7 +78,8 @@ describe("KeyboardUserSettingsTab", () => {
case "keybind2": {
return {
key: Key.B,
ctrlKey: true };
ctrlKey: true,
};
}
case "keybind3": {
return {
@@ -89,7 +88,7 @@ describe("KeyboardUserSettingsTab", () => {
}
}
},
"getKeyboardShortcutDisplayName": (name) => {
getKeyboardShortcutDisplayName: (name) => {
switch (name) {
case "keybind1":
return "Cancel replying to a message";
@@ -14,33 +14,33 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import React from 'react';
import { render } from '@testing-library/react';
import React from "react";
import { render } from "@testing-library/react";
import LabsUserSettingsTab from '../../../../../../src/components/views/settings/tabs/user/LabsUserSettingsTab';
import SettingsStore from '../../../../../../src/settings/SettingsStore';
import LabsUserSettingsTab from "../../../../../../src/components/views/settings/tabs/user/LabsUserSettingsTab";
import SettingsStore from "../../../../../../src/settings/SettingsStore";
import {
getMockClientWithEventEmitter,
mockClientMethodsServer,
mockClientMethodsUser,
} from '../../../../../test-utils';
import SdkConfig from '../../../../../../src/SdkConfig';
} from "../../../../../test-utils";
import SdkConfig from "../../../../../../src/SdkConfig";
describe('<SecurityUserSettingsTab />', () => {
const sdkConfigSpy = jest.spyOn(SdkConfig, 'get');
describe("<SecurityUserSettingsTab />", () => {
const sdkConfigSpy = jest.spyOn(SdkConfig, "get");
const defaultProps = {
closeSettingsFn: jest.fn(),
};
const getComponent = () => <LabsUserSettingsTab {...defaultProps} />;
const userId = '@alice:server.org';
const userId = "@alice:server.org";
getMockClientWithEventEmitter({
...mockClientMethodsUser(userId),
...mockClientMethodsServer(),
});
const settingsValueSpy = jest.spyOn(SettingsStore, 'getValue');
const settingsValueSpy = jest.spyOn(SettingsStore, "getValue");
beforeEach(() => {
jest.clearAllMocks();
@@ -48,26 +48,26 @@ describe('<SecurityUserSettingsTab />', () => {
sdkConfigSpy.mockReturnValue(false);
});
it('renders settings marked as beta as beta cards', () => {
it("renders settings marked as beta as beta cards", () => {
const { getByTestId } = render(getComponent());
expect(getByTestId("labs-beta-section")).toMatchSnapshot();
});
it('does not render non-beta labs settings when disabled in config', () => {
it("does not render non-beta labs settings when disabled in config", () => {
const { container } = render(getComponent());
expect(sdkConfigSpy).toHaveBeenCalledWith('show_labs_settings');
expect(sdkConfigSpy).toHaveBeenCalledWith("show_labs_settings");
const labsSections = container.getElementsByClassName('mx_SettingsTab_section');
const labsSections = container.getElementsByClassName("mx_SettingsTab_section");
// only section is beta section
expect(labsSections.length).toEqual(1);
});
it('renders non-beta labs settings when enabled in config', () => {
it("renders non-beta labs settings when enabled in config", () => {
// enable labs
sdkConfigSpy.mockImplementation(configName => configName === 'show_labs_settings');
sdkConfigSpy.mockImplementation((configName) => configName === "show_labs_settings");
const { container } = render(getComponent());
const labsSections = container.getElementsByClassName('mx_SettingsTab_section');
const labsSections = container.getElementsByClassName("mx_SettingsTab_section");
expect(labsSections.length).toEqual(11);
});
});
@@ -17,8 +17,7 @@ limitations under the License.
import React from "react";
import { fireEvent, render, RenderResult, waitFor } from "@testing-library/react";
import PreferencesUserSettingsTab from
"../../../../../../src/components/views/settings/tabs/user/PreferencesUserSettingsTab";
import PreferencesUserSettingsTab from "../../../../../../src/components/views/settings/tabs/user/PreferencesUserSettingsTab";
import { MatrixClientPeg } from "../../../../../../src/MatrixClientPeg";
import { mockPlatformPeg, stubClient } from "../../../../../test-utils";
import SettingsStore from "../../../../../../src/settings/SettingsStore";
@@ -62,12 +61,8 @@ describe("PreferencesUserSettingsTab", () => {
};
};
const expectSetValueToHaveBeenCalled = (
name: string,
roomId: string,
level: SettingLevel,
value: boolean,
) => expect(SettingsStore.setValue).toHaveBeenCalledWith(name, roomId, level, value);
const expectSetValueToHaveBeenCalled = (name: string, roomId: string, level: SettingLevel, value: boolean) =>
expect(SettingsStore.setValue).toHaveBeenCalledWith(name, roomId, level, value);
describe("with server support", () => {
beforeEach(() => {
@@ -13,12 +13,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { fireEvent, render } from '@testing-library/react';
import React from 'react';
import { fireEvent, render } from "@testing-library/react";
import React from "react";
import SecurityUserSettingsTab from "../../../../../../src/components/views/settings/tabs/user/SecurityUserSettingsTab";
import MatrixClientContext from '../../../../../../src/contexts/MatrixClientContext';
import SettingsStore from '../../../../../../src/settings/SettingsStore';
import MatrixClientContext from "../../../../../../src/contexts/MatrixClientContext";
import SettingsStore from "../../../../../../src/settings/SettingsStore";
import {
getMockClientWithEventEmitter,
mockClientMethodsServer,
@@ -27,15 +27,15 @@ import {
mockClientMethodsDevice,
mockPlatformPeg,
flushPromises,
} from '../../../../../test-utils';
} from "../../../../../test-utils";
describe('<SecurityUserSettingsTab />', () => {
describe("<SecurityUserSettingsTab />", () => {
const defaultProps = {
closeSettingsFn: jest.fn(),
};
const userId = '@alice:server.org';
const deviceId = 'alices-device';
const userId = "@alice:server.org";
const deviceId = "alices-device";
const mockClient = getMockClientWithEventEmitter({
...mockClientMethodsUser(userId),
...mockClientMethodsServer(),
@@ -45,18 +45,19 @@ describe('<SecurityUserSettingsTab />', () => {
getIgnoredUsers: jest.fn(),
getVersions: jest.fn().mockResolvedValue({
unstable_features: {
'org.matrix.msc3882': true,
'org.matrix.msc3886': true,
"org.matrix.msc3882": true,
"org.matrix.msc3886": true,
},
}),
});
const getComponent = () =>
const getComponent = () => (
<MatrixClientContext.Provider value={mockClient}>
<SecurityUserSettingsTab {...defaultProps} />
</MatrixClientContext.Provider>;
</MatrixClientContext.Provider>
);
const settingsValueSpy = jest.spyOn(SettingsStore, 'getValue');
const settingsValueSpy = jest.spyOn(SettingsStore, "getValue");
beforeEach(() => {
mockPlatformPeg();
@@ -64,46 +65,46 @@ describe('<SecurityUserSettingsTab />', () => {
settingsValueSpy.mockReturnValue(false);
});
it('renders sessions section when new session manager is disabled', () => {
it("renders sessions section when new session manager is disabled", () => {
settingsValueSpy.mockReturnValue(false);
const { getByTestId } = render(getComponent());
expect(getByTestId('devices-section')).toBeTruthy();
expect(getByTestId("devices-section")).toBeTruthy();
});
it('does not render sessions section when new session manager is enabled', () => {
it("does not render sessions section when new session manager is enabled", () => {
settingsValueSpy.mockReturnValue(true);
const { queryByTestId } = render(getComponent());
expect(queryByTestId('devices-section')).toBeFalsy();
expect(queryByTestId("devices-section")).toBeFalsy();
});
it('does not render qr code login section when disabled', () => {
it("does not render qr code login section when disabled", () => {
settingsValueSpy.mockReturnValue(false);
const { queryByText } = render(getComponent());
expect(settingsValueSpy).toHaveBeenCalledWith('feature_qr_signin_reciprocate_show');
expect(settingsValueSpy).toHaveBeenCalledWith("feature_qr_signin_reciprocate_show");
expect(queryByText('Sign in with QR code')).toBeFalsy();
expect(queryByText("Sign in with QR code")).toBeFalsy();
});
it('renders qr code login section when enabled', async () => {
settingsValueSpy.mockImplementation(settingName => settingName === 'feature_qr_signin_reciprocate_show');
it("renders qr code login section when enabled", async () => {
settingsValueSpy.mockImplementation((settingName) => settingName === "feature_qr_signin_reciprocate_show");
const { getByText } = render(getComponent());
// wait for versions call to settle
await flushPromises();
expect(getByText('Sign in with QR code')).toBeTruthy();
expect(getByText("Sign in with QR code")).toBeTruthy();
});
it('enters qr code login section when show QR code button clicked', async () => {
settingsValueSpy.mockImplementation(settingName => settingName === 'feature_qr_signin_reciprocate_show');
it("enters qr code login section when show QR code button clicked", async () => {
settingsValueSpy.mockImplementation((settingName) => settingName === "feature_qr_signin_reciprocate_show");
const { getByText, getByTestId } = render(getComponent());
// wait for versions call to settle
await flushPromises();
fireEvent.click(getByText('Show QR code'));
fireEvent.click(getByText("Show QR code"));
expect(getByTestId("login-with-qr")).toBeTruthy();
});
File diff suppressed because it is too large Load Diff
@@ -14,31 +14,31 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import React from 'react';
import { mocked } from 'jest-mock';
import { render } from '@testing-library/react';
import React from "react";
import { mocked } from "jest-mock";
import { render } from "@testing-library/react";
import VoiceUserSettingsTab from '../../../../../../src/components/views/settings/tabs/user/VoiceUserSettingsTab';
import VoiceUserSettingsTab from "../../../../../../src/components/views/settings/tabs/user/VoiceUserSettingsTab";
import MediaDeviceHandler from "../../../../../../src/MediaDeviceHandler";
jest.mock("../../../../../../src/MediaDeviceHandler");
const MediaDeviceHandlerMock = mocked(MediaDeviceHandler);
describe('<VoiceUserSettingsTab />', () => {
const getComponent = (): React.ReactElement => (<VoiceUserSettingsTab />);
describe("<VoiceUserSettingsTab />", () => {
const getComponent = (): React.ReactElement => <VoiceUserSettingsTab />;
beforeEach(() => {
jest.clearAllMocks();
});
it('renders audio processing settings', () => {
it("renders audio processing settings", () => {
const { getByTestId } = render(getComponent());
expect(getByTestId('voice-auto-gain')).toBeTruthy();
expect(getByTestId('voice-noise-suppression')).toBeTruthy();
expect(getByTestId('voice-echo-cancellation')).toBeTruthy();
expect(getByTestId("voice-auto-gain")).toBeTruthy();
expect(getByTestId("voice-noise-suppression")).toBeTruthy();
expect(getByTestId("voice-echo-cancellation")).toBeTruthy();
});
it('sets and displays audio processing settings', () => {
it("sets and displays audio processing settings", () => {
MediaDeviceHandlerMock.getAudioAutoGainControl.mockReturnValue(false);
MediaDeviceHandlerMock.getAudioEchoCancellation.mockReturnValue(true);
MediaDeviceHandlerMock.getAudioNoiseSuppression.mockReturnValue(false);