2022-10-11 11:10:55 +02:00
|
|
|
/*
|
2024-09-09 15:57:16 +02:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2022-10-11 11:10:55 +02:00
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
2024-09-09 15:57:16 +02:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2022-10-11 11:10:55 +02:00
|
|
|
*/
|
2023-05-26 03:58:28 +02:00
|
|
|
import { render } from "@testing-library/react";
|
2022-12-12 12:24:14 +01:00
|
|
|
import React from "react";
|
2022-10-11 11:10:55 +02:00
|
|
|
|
|
|
|
import SecurityUserSettingsTab from "../../../../../../src/components/views/settings/tabs/user/SecurityUserSettingsTab";
|
2022-12-12 12:24:14 +01:00
|
|
|
import MatrixClientContext from "../../../../../../src/contexts/MatrixClientContext";
|
2022-10-11 11:10:55 +02:00
|
|
|
import {
|
|
|
|
getMockClientWithEventEmitter,
|
|
|
|
mockClientMethodsServer,
|
|
|
|
mockClientMethodsUser,
|
|
|
|
mockClientMethodsCrypto,
|
|
|
|
mockClientMethodsDevice,
|
|
|
|
mockPlatformPeg,
|
2022-12-12 12:24:14 +01:00
|
|
|
} from "../../../../../test-utils";
|
2024-04-15 17:47:15 +02:00
|
|
|
import { SDKContext, SdkContextClass } from "../../../../../../src/contexts/SDKContext";
|
2022-10-11 11:10:55 +02:00
|
|
|
|
2022-12-12 12:24:14 +01:00
|
|
|
describe("<SecurityUserSettingsTab />", () => {
|
2022-10-11 11:10:55 +02:00
|
|
|
const defaultProps = {
|
|
|
|
closeSettingsFn: jest.fn(),
|
|
|
|
};
|
|
|
|
|
2022-12-12 12:24:14 +01:00
|
|
|
const userId = "@alice:server.org";
|
|
|
|
const deviceId = "alices-device";
|
2022-10-19 14:31:20 +02:00
|
|
|
const mockClient = getMockClientWithEventEmitter({
|
2022-10-11 11:10:55 +02:00
|
|
|
...mockClientMethodsUser(userId),
|
|
|
|
...mockClientMethodsServer(),
|
|
|
|
...mockClientMethodsDevice(deviceId),
|
|
|
|
...mockClientMethodsCrypto(),
|
|
|
|
getRooms: jest.fn().mockReturnValue([]),
|
|
|
|
getIgnoredUsers: jest.fn(),
|
2023-09-21 14:19:38 +02:00
|
|
|
getKeyBackupVersion: jest.fn(),
|
2022-10-11 11:10:55 +02:00
|
|
|
});
|
|
|
|
|
2024-04-15 17:47:15 +02:00
|
|
|
const sdkContext = new SdkContextClass();
|
|
|
|
sdkContext.client = mockClient;
|
|
|
|
|
2022-12-12 12:24:14 +01:00
|
|
|
const getComponent = () => (
|
2022-10-19 14:31:20 +02:00
|
|
|
<MatrixClientContext.Provider value={mockClient}>
|
2024-04-15 17:47:15 +02:00
|
|
|
<SDKContext.Provider value={sdkContext}>
|
|
|
|
<SecurityUserSettingsTab {...defaultProps} />
|
|
|
|
</SDKContext.Provider>
|
2022-12-12 12:24:14 +01:00
|
|
|
</MatrixClientContext.Provider>
|
|
|
|
);
|
2022-10-19 14:31:20 +02:00
|
|
|
|
2022-10-11 11:10:55 +02:00
|
|
|
beforeEach(() => {
|
|
|
|
mockPlatformPeg();
|
|
|
|
jest.clearAllMocks();
|
2022-10-19 17:11:42 +02:00
|
|
|
});
|
|
|
|
|
2023-05-26 03:58:28 +02:00
|
|
|
it("renders security section", () => {
|
|
|
|
const { container } = render(getComponent());
|
2022-10-19 17:11:42 +02:00
|
|
|
|
2023-05-26 03:58:28 +02:00
|
|
|
expect(container).toMatchSnapshot();
|
2022-10-19 17:11:42 +02:00
|
|
|
});
|
2022-10-11 11:10:55 +02:00
|
|
|
});
|