Simplify references to VerificationRequest
(#11045)
* Use new `VerificationRequest.getQRCodeBytes()` * Use new `VerificationRequest.otherDeviceId` * Remove references to `VerificationRequest.channel` * Replace references to `VerificationRequest.{requesting,receiving}UserId` Normally these are guarded by `request.initiatedByMe` so we can trivially replace it with `request.otherUserId` or `client.getUserId()`. In one place we actually need to apply some logic. * increase test coverage * Even more test coverage * Even more test coverage
This commit is contained in:
parent
ac2c9cef8d
commit
34439ee652
12 changed files with 310 additions and 33 deletions
|
@ -15,7 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React from "react";
|
||||
import { render } from "@testing-library/react";
|
||||
import { render, within } from "@testing-library/react";
|
||||
import { EventEmitter } from "events";
|
||||
import { MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||
import {
|
||||
|
@ -74,6 +74,29 @@ describe("MKeyVerificationRequest", () => {
|
|||
expect(container).toHaveTextContent("You sent a verification request");
|
||||
});
|
||||
|
||||
it("should render appropriately when the request was initiated by me and has been accepted", () => {
|
||||
const event = new MatrixEvent({ type: "m.key.verification.request" });
|
||||
event.verificationRequest = getMockVerificationRequest({
|
||||
phase: VerificationPhase.Ready,
|
||||
otherUserId: "@other:user",
|
||||
});
|
||||
const { container } = render(<MKeyVerificationRequest mxEvent={event} />);
|
||||
expect(container).toHaveTextContent("You sent a verification request");
|
||||
expect(within(container).getByRole("button")).toHaveTextContent("@other:user accepted");
|
||||
});
|
||||
|
||||
it("should render appropriately when the request was initiated by the other user and has been accepted", () => {
|
||||
const event = new MatrixEvent({ type: "m.key.verification.request" });
|
||||
event.verificationRequest = getMockVerificationRequest({
|
||||
phase: VerificationPhase.Ready,
|
||||
initiatedByMe: false,
|
||||
otherUserId: "@other:user",
|
||||
});
|
||||
const { container } = render(<MKeyVerificationRequest mxEvent={event} />);
|
||||
expect(container).toHaveTextContent("@other:user wants to verify");
|
||||
expect(within(container).getByRole("button")).toHaveTextContent("You accepted");
|
||||
});
|
||||
|
||||
it("should render appropriately when the request was cancelled", () => {
|
||||
const event = new MatrixEvent({ type: "m.key.verification.request" });
|
||||
event.verificationRequest = getMockVerificationRequest({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue