Update to use non deprecated methods to decode recovery key (#54)
* Replace `MatrixClient.keyBackupKeyFromRecoveryKey` by `decodeRecoveryKey` * Replace `MatrixClient.isValidRecoveryKey` by local check with `decodeRecoveryKey` * Replace old `decodeRecoveryKey` import * Remove `matrix-js-sdk/src/crypto/recoverykey` import of eslint exception * Add tests for `RestoreKeyBackupDialog`
This commit is contained in:
@@ -58,15 +58,12 @@ describe("AccessSecretStorageDialog", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
mockClient = getMockClientWithEventEmitter({
|
||||
keyBackupKeyFromRecoveryKey: jest.fn(),
|
||||
checkSecretStorageKey: jest.fn(),
|
||||
isValidRecoveryKey: jest.fn(),
|
||||
});
|
||||
});
|
||||
|
||||
it("Closes the dialog when the form is submitted with a valid key", async () => {
|
||||
mockClient.checkSecretStorageKey.mockResolvedValue(true);
|
||||
mockClient.isValidRecoveryKey.mockReturnValue(true);
|
||||
|
||||
const onFinished = jest.fn();
|
||||
const checkPrivateKey = jest.fn().mockResolvedValue(true);
|
||||
@@ -88,8 +85,8 @@ describe("AccessSecretStorageDialog", () => {
|
||||
const checkPrivateKey = jest.fn().mockResolvedValue(true);
|
||||
renderComponent({ onFinished, checkPrivateKey });
|
||||
|
||||
mockClient.keyBackupKeyFromRecoveryKey.mockImplementation(() => {
|
||||
throw new Error("that's no key");
|
||||
mockClient.checkSecretStorageKey.mockImplementation(() => {
|
||||
throw new Error("invalid key");
|
||||
});
|
||||
|
||||
await enterSecurityKey();
|
||||
@@ -115,7 +112,6 @@ describe("AccessSecretStorageDialog", () => {
|
||||
};
|
||||
const checkPrivateKey = jest.fn().mockResolvedValue(false);
|
||||
renderComponent({ checkPrivateKey, keyInfo });
|
||||
mockClient.isValidRecoveryKey.mockReturnValue(false);
|
||||
|
||||
await enterSecurityKey("Security Phrase");
|
||||
expect(screen.getByPlaceholderText("Security Phrase")).toHaveValue(securityKey);
|
||||
|
||||
Reference in New Issue
Block a user