2022-10-11 17:10:55 +08: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 09:58:28 +08:00
|
|
|
import { render } from "@testing-library/react";
|
2022-10-11 17:10:55 +08:00
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
import SecurityUserSettingsTab from "../../../../../../src/components/views/settings/tabs/user/SecurityUserSettingsTab";
|
2022-10-19 20:31:20 +08:00
|
|
|
import MatrixClientContext from "../../../../../../src/contexts/MatrixClientContext";
|
2022-10-11 17:10:55 +08:00
|
|
|
import {
|
|
|
|
getMockClientWithEventEmitter,
|
|
|
|
mockClientMethodsServer,
|
|
|
|
mockClientMethodsUser,
|
|
|
|
mockClientMethodsCrypto,
|
|
|
|
mockClientMethodsDevice,
|
|
|
|
mockPlatformPeg,
|
|
|
|
} from "../../../../../test-utils";
|
|
|
|
|
|
|
|
describe("<SecurityUserSettingsTab />", () => {
|
|
|
|
const defaultProps = {
|
|
|
|
closeSettingsFn: jest.fn(),
|
|
|
|
};
|
|
|
|
|
|
|
|
const userId = "@alice:server.org";
|
|
|
|
const deviceId = "alices-device";
|
2022-10-19 20:31:20 +08:00
|
|
|
const mockClient = getMockClientWithEventEmitter({
|
2022-10-11 17:10:55 +08:00
|
|
|
...mockClientMethodsUser(userId),
|
|
|
|
...mockClientMethodsServer(),
|
|
|
|
...mockClientMethodsDevice(deviceId),
|
|
|
|
...mockClientMethodsCrypto(),
|
|
|
|
getRooms: jest.fn().mockReturnValue([]),
|
|
|
|
getIgnoredUsers: jest.fn(),
|
2023-09-21 20:19:38 +08:00
|
|
|
getKeyBackupVersion: jest.fn(),
|
2022-10-11 17:10:55 +08:00
|
|
|
});
|
|
|
|
|
2022-10-19 20:31:20 +08:00
|
|
|
const getComponent = () => (
|
|
|
|
<MatrixClientContext.Provider value={mockClient}>
|
|
|
|
<SecurityUserSettingsTab {...defaultProps} />
|
|
|
|
</MatrixClientContext.Provider>
|
|
|
|
);
|
|
|
|
|
2022-10-11 17:10:55 +08:00
|
|
|
beforeEach(() => {
|
|
|
|
mockPlatformPeg();
|
|
|
|
jest.clearAllMocks();
|
2022-10-19 23:11:42 +08:00
|
|
|
});
|
|
|
|
|
2023-05-26 09:58:28 +08:00
|
|
|
it("renders security section", () => {
|
|
|
|
const { container } = render(getComponent());
|
2022-10-19 23:11:42 +08:00
|
|
|
|
2023-05-26 09:58:28 +08:00
|
|
|
expect(container).toMatchSnapshot();
|
2022-10-19 23:11:42 +08:00
|
|
|
});
|
2022-10-11 17:10:55 +08:00
|
|
|
});
|