diff --git a/src/SecurityManager.ts b/src/SecurityManager.ts index fb73e25389..a89427e5f3 100644 --- a/src/SecurityManager.ts +++ b/src/SecurityManager.ts @@ -121,7 +121,7 @@ async function getSecretStorageKey({ keyInfo, checkPrivateKey: async (input: KeyParams): Promise => { const key = await inputToKey(input); - return MatrixClientPeg.safeGet().checkSecretStorageKey(key, keyInfo); + return MatrixClientPeg.safeGet().secretStorage.checkKey(key, keyInfo); }, }, /* className= */ undefined, diff --git a/src/components/views/dialogs/security/AccessSecretStorageDialog.tsx b/src/components/views/dialogs/security/AccessSecretStorageDialog.tsx index 0c4e875607..412d88c704 100644 --- a/src/components/views/dialogs/security/AccessSecretStorageDialog.tsx +++ b/src/components/views/dialogs/security/AccessSecretStorageDialog.tsx @@ -102,7 +102,7 @@ export default class AccessSecretStorageDialog extends React.PureComponent { - let mockClient: Mocked; + let mockClient: MatrixClient; const defaultProps: ComponentProps = { keyInfo: {} as any, @@ -57,13 +56,14 @@ describe("AccessSecretStorageDialog", () => { }); beforeEach(() => { - mockClient = getMockClientWithEventEmitter({ - checkSecretStorageKey: jest.fn(), - }); + // mockClient = getMockClientWithEventEmitter({ + // checkSecretStorageKey: jest.fn(), + // }); + mockClient = stubClient(); }); it("Closes the dialog when the form is submitted with a valid key", async () => { - mockClient.checkSecretStorageKey.mockResolvedValue(true); + jest.spyOn(mockClient.secretStorage, "checkKey").mockResolvedValue(true); const onFinished = jest.fn(); const checkPrivateKey = jest.fn().mockResolvedValue(true); @@ -85,7 +85,7 @@ describe("AccessSecretStorageDialog", () => { const checkPrivateKey = jest.fn().mockResolvedValue(true); renderComponent({ onFinished, checkPrivateKey }); - mockClient.checkSecretStorageKey.mockImplementation(() => { + jest.spyOn(mockClient.secretStorage, "checkKey").mockImplementation(() => { throw new Error("invalid key"); }); diff --git a/test/test-utils/test-utils.ts b/test/test-utils/test-utils.ts index ebfc6b221b..2f534c7bd7 100644 --- a/test/test-utils/test-utils.ts +++ b/test/test-utils/test-utils.ts @@ -109,6 +109,7 @@ export function createTestClient(): MatrixClient { secretStorage: { get: jest.fn(), isStored: jest.fn().mockReturnValue(false), + checkKey: jest.fn().mockResolvedValue(false), }, store: {