2022-10-11 09:10:55 +00:00
|
|
|
/*
|
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
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.
|
|
|
|
*/
|
2023-05-26 01:58:28 +00:00
|
|
|
import { render } from "@testing-library/react";
|
2022-12-12 11:24:14 +00:00
|
|
|
import React from "react";
|
2022-10-11 09:10:55 +00:00
|
|
|
|
|
|
|
import SecurityUserSettingsTab from "../../../../../../src/components/views/settings/tabs/user/SecurityUserSettingsTab";
|
2022-12-12 11:24:14 +00:00
|
|
|
import MatrixClientContext from "../../../../../../src/contexts/MatrixClientContext";
|
2022-10-11 09:10:55 +00:00
|
|
|
import {
|
|
|
|
getMockClientWithEventEmitter,
|
|
|
|
mockClientMethodsServer,
|
|
|
|
mockClientMethodsUser,
|
|
|
|
mockClientMethodsCrypto,
|
|
|
|
mockClientMethodsDevice,
|
|
|
|
mockPlatformPeg,
|
2022-12-12 11:24:14 +00:00
|
|
|
} from "../../../../../test-utils";
|
2024-04-15 15:47:15 +00:00
|
|
|
import { SDKContext, SdkContextClass } from "../../../../../../src/contexts/SDKContext";
|
2022-10-11 09:10:55 +00:00
|
|
|
|
2022-12-12 11:24:14 +00:00
|
|
|
describe("<SecurityUserSettingsTab />", () => {
|
2022-10-11 09:10:55 +00:00
|
|
|
const defaultProps = {
|
|
|
|
closeSettingsFn: jest.fn(),
|
|
|
|
};
|
|
|
|
|
2022-12-12 11:24:14 +00:00
|
|
|
const userId = "@alice:server.org";
|
|
|
|
const deviceId = "alices-device";
|
2022-10-19 12:31:20 +00:00
|
|
|
const mockClient = getMockClientWithEventEmitter({
|
2022-10-11 09:10:55 +00:00
|
|
|
...mockClientMethodsUser(userId),
|
|
|
|
...mockClientMethodsServer(),
|
|
|
|
...mockClientMethodsDevice(deviceId),
|
|
|
|
...mockClientMethodsCrypto(),
|
|
|
|
getRooms: jest.fn().mockReturnValue([]),
|
|
|
|
getIgnoredUsers: jest.fn(),
|
2023-09-21 12:19:38 +00:00
|
|
|
getKeyBackupVersion: jest.fn(),
|
2022-10-11 09:10:55 +00:00
|
|
|
});
|
|
|
|
|
2024-04-15 15:47:15 +00:00
|
|
|
const sdkContext = new SdkContextClass();
|
|
|
|
sdkContext.client = mockClient;
|
|
|
|
|
2022-12-12 11:24:14 +00:00
|
|
|
const getComponent = () => (
|
2022-10-19 12:31:20 +00:00
|
|
|
<MatrixClientContext.Provider value={mockClient}>
|
2024-04-15 15:47:15 +00:00
|
|
|
<SDKContext.Provider value={sdkContext}>
|
|
|
|
<SecurityUserSettingsTab {...defaultProps} />
|
|
|
|
</SDKContext.Provider>
|
2022-12-12 11:24:14 +00:00
|
|
|
</MatrixClientContext.Provider>
|
|
|
|
);
|
2022-10-19 12:31:20 +00:00
|
|
|
|
2022-10-11 09:10:55 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
mockPlatformPeg();
|
|
|
|
jest.clearAllMocks();
|
2022-10-19 15:11:42 +00:00
|
|
|
});
|
|
|
|
|
2023-05-26 01:58:28 +00:00
|
|
|
it("renders security section", () => {
|
|
|
|
const { container } = render(getComponent());
|
2022-10-19 15:11:42 +00:00
|
|
|
|
2023-05-26 01:58:28 +00:00
|
|
|
expect(container).toMatchSnapshot();
|
2022-10-19 15:11:42 +00:00
|
|
|
});
|
2022-10-11 09:10:55 +00:00
|
|
|
});
|