Remove references to VerificationRequest
(#11050)
* Update references to `VerificationRequestEvent` * Update references to `Phase` * update references to legacy `PHASE_*` constants * Replace `request.canAccept` with `canAcceptVerificationRequest` * Replace `VerificationRequest` with the interface throughout * Minor strict type fixes * Add a couple of tests
This commit is contained in:
parent
6486255f54
commit
b9b93264b6
20 changed files with 72 additions and 57 deletions
|
@ -27,6 +27,7 @@ import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"
|
|||
|
||||
import VerificationRequestToast from "../../../../src/components/views/toasts/VerificationRequestToast";
|
||||
import { flushPromises, getMockClientWithEventEmitter, mockClientMethodsUser } from "../../../test-utils";
|
||||
import ToastStore from "../../../../src/stores/ToastStore";
|
||||
|
||||
function renderComponent(
|
||||
props: Partial<ComponentProps<typeof VerificationRequestToast>> & { request: VerificationRequest },
|
||||
|
@ -82,6 +83,23 @@ describe("VerificationRequestToast", () => {
|
|||
});
|
||||
expect(result.container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("dismisses itself once the request can no longer be accepted", async () => {
|
||||
const otherUserId = "@other:user";
|
||||
const request = makeMockVerificationRequest({
|
||||
isSelfVerification: false,
|
||||
otherUserId,
|
||||
});
|
||||
renderComponent({ request, toastKey: "testKey" });
|
||||
await act(async () => {
|
||||
await flushPromises();
|
||||
});
|
||||
|
||||
const dismiss = jest.spyOn(ToastStore.sharedInstance(), "dismissToast");
|
||||
Object.defineProperty(request, "accepting", { value: true });
|
||||
request.emit(VerificationRequestEvent.Change);
|
||||
expect(dismiss).toHaveBeenCalledWith("testKey");
|
||||
});
|
||||
});
|
||||
|
||||
function makeMockVerificationRequest(props: Partial<VerificationRequest> = {}): Mocked<VerificationRequest> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue