mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-27 12:08:38 +00:00
Apply prettier formatting
This commit is contained in:
@@ -14,33 +14,40 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import TestRenderer from 'react-test-renderer';
|
||||
import { EventEmitter } from 'events';
|
||||
import { MatrixEvent, EventType } from 'matrix-js-sdk/src/matrix';
|
||||
import { CryptoEvent } from 'matrix-js-sdk/src/crypto';
|
||||
import { UserTrustLevel } from 'matrix-js-sdk/src/crypto/CrossSigning';
|
||||
import { VerificationRequest } from 'matrix-js-sdk/src/crypto/verification/request/VerificationRequest';
|
||||
import React from "react";
|
||||
import TestRenderer from "react-test-renderer";
|
||||
import { EventEmitter } from "events";
|
||||
import { MatrixEvent, EventType } from "matrix-js-sdk/src/matrix";
|
||||
import { CryptoEvent } from "matrix-js-sdk/src/crypto";
|
||||
import { UserTrustLevel } from "matrix-js-sdk/src/crypto/CrossSigning";
|
||||
import { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
||||
|
||||
import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';
|
||||
import MKeyVerificationConclusion from '../../../../src/components/views/messages/MKeyVerificationConclusion';
|
||||
import { getMockClientWithEventEmitter } from '../../../test-utils';
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
import MKeyVerificationConclusion from "../../../../src/components/views/messages/MKeyVerificationConclusion";
|
||||
import { getMockClientWithEventEmitter } from "../../../test-utils";
|
||||
|
||||
const trustworthy = ({ isCrossSigningVerified: () => true }) as unknown as UserTrustLevel;
|
||||
const untrustworthy = ({ isCrossSigningVerified: () => false }) as unknown as UserTrustLevel;
|
||||
const trustworthy = { isCrossSigningVerified: () => true } as unknown as UserTrustLevel;
|
||||
const untrustworthy = { isCrossSigningVerified: () => false } as unknown as UserTrustLevel;
|
||||
|
||||
describe("MKeyVerificationConclusion", () => {
|
||||
const userId = '@user:server';
|
||||
const userId = "@user:server";
|
||||
const mockClient = getMockClientWithEventEmitter({
|
||||
getRoom: jest.fn(),
|
||||
getUserId: jest.fn().mockReturnValue(userId),
|
||||
checkUserTrust: jest.fn(),
|
||||
});
|
||||
|
||||
const getMockVerificationRequest = (
|
||||
{ pending, cancelled, done, otherUserId }:
|
||||
{ pending?: boolean, cancelled?: boolean, done?: boolean, otherUserId?: string },
|
||||
) => {
|
||||
const getMockVerificationRequest = ({
|
||||
pending,
|
||||
cancelled,
|
||||
done,
|
||||
otherUserId,
|
||||
}: {
|
||||
pending?: boolean;
|
||||
cancelled?: boolean;
|
||||
done?: boolean;
|
||||
otherUserId?: string;
|
||||
}) => {
|
||||
class MockVerificationRequest extends EventEmitter {
|
||||
constructor(
|
||||
public readonly pending: boolean,
|
||||
@@ -60,41 +67,33 @@ describe("MKeyVerificationConclusion", () => {
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
jest.spyOn(MatrixClientPeg, 'get').mockRestore();
|
||||
jest.spyOn(MatrixClientPeg, "get").mockRestore();
|
||||
});
|
||||
|
||||
it("shouldn't render if there's no verificationRequest", () => {
|
||||
const event = new MatrixEvent({});
|
||||
const renderer = TestRenderer.create(
|
||||
<MKeyVerificationConclusion mxEvent={event} />,
|
||||
);
|
||||
const renderer = TestRenderer.create(<MKeyVerificationConclusion mxEvent={event} />);
|
||||
expect(renderer.toJSON()).toBeNull();
|
||||
});
|
||||
|
||||
it("shouldn't render if the verificationRequest is pending", () => {
|
||||
const event = new MatrixEvent({});
|
||||
event.verificationRequest = getMockVerificationRequest({ pending: true });
|
||||
const renderer = TestRenderer.create(
|
||||
<MKeyVerificationConclusion mxEvent={event} />,
|
||||
);
|
||||
const renderer = TestRenderer.create(<MKeyVerificationConclusion mxEvent={event} />);
|
||||
expect(renderer.toJSON()).toBeNull();
|
||||
});
|
||||
|
||||
it("shouldn't render if the event type is cancel but the request type isn't", () => {
|
||||
const event = new MatrixEvent({ type: EventType.KeyVerificationCancel });
|
||||
event.verificationRequest = getMockVerificationRequest({ cancelled: false });
|
||||
const renderer = TestRenderer.create(
|
||||
<MKeyVerificationConclusion mxEvent={event} />,
|
||||
);
|
||||
const renderer = TestRenderer.create(<MKeyVerificationConclusion mxEvent={event} />);
|
||||
expect(renderer.toJSON()).toBeNull();
|
||||
});
|
||||
|
||||
it("shouldn't render if the event type is done but the request type isn't", () => {
|
||||
const event = new MatrixEvent({ type: "m.key.verification.done" });
|
||||
event.verificationRequest = getMockVerificationRequest({ done: false });
|
||||
const renderer = TestRenderer.create(
|
||||
<MKeyVerificationConclusion mxEvent={event} />,
|
||||
);
|
||||
const renderer = TestRenderer.create(<MKeyVerificationConclusion mxEvent={event} />);
|
||||
expect(renderer.toJSON()).toBeNull();
|
||||
});
|
||||
|
||||
@@ -103,9 +102,7 @@ describe("MKeyVerificationConclusion", () => {
|
||||
|
||||
const event = new MatrixEvent({ type: "m.key.verification.done" });
|
||||
event.verificationRequest = getMockVerificationRequest({ done: true });
|
||||
const renderer = TestRenderer.create(
|
||||
<MKeyVerificationConclusion mxEvent={event} />,
|
||||
);
|
||||
const renderer = TestRenderer.create(<MKeyVerificationConclusion mxEvent={event} />);
|
||||
expect(renderer.toJSON()).toBeNull();
|
||||
});
|
||||
|
||||
@@ -114,9 +111,7 @@ describe("MKeyVerificationConclusion", () => {
|
||||
|
||||
const event = new MatrixEvent({ type: "m.key.verification.done" });
|
||||
event.verificationRequest = getMockVerificationRequest({ done: true, otherUserId: "@someuser:domain" });
|
||||
const renderer = TestRenderer.create(
|
||||
<MKeyVerificationConclusion mxEvent={event} />,
|
||||
);
|
||||
const renderer = TestRenderer.create(<MKeyVerificationConclusion mxEvent={event} />);
|
||||
expect(renderer.toJSON()).toBeNull();
|
||||
|
||||
mockClient.checkUserTrust.mockReturnValue(trustworthy);
|
||||
|
||||
Reference in New Issue
Block a user