Fix tests
This commit is contained in:
parent
916f606872
commit
0579c9f748
2 changed files with 20 additions and 16 deletions
|
@ -40,19 +40,20 @@ describe("AccessSecretStorageDialog", function() {
|
|||
testInstance.getInstance()._onRecoveryKeyNext(e);
|
||||
});
|
||||
|
||||
it("Considers a valid key to be valid", function() {
|
||||
it("Considers a valid key to be valid", async function() {
|
||||
const testInstance = TestRenderer.create(
|
||||
<AccessSecretStorageDialog
|
||||
checkPrivateKey={() => true}
|
||||
/>,
|
||||
);
|
||||
const v = "asfd";
|
||||
const v = "asdf";
|
||||
const e = { target: { value: v } };
|
||||
stubClient();
|
||||
MatrixClientPeg.get().isValidRecoveryKey = function(k) {
|
||||
return k == v;
|
||||
};
|
||||
MatrixClientPeg.get().keyBackupKeyFromRecoveryKey = () => 'a raw key';
|
||||
MatrixClientPeg.get().checkSecretStorageKey = () => true;
|
||||
testInstance.getInstance()._onRecoveryKeyChange(e);
|
||||
// force a validation now because it debounces
|
||||
await testInstance.getInstance()._validateRecoveryKey();
|
||||
const { recoveryKeyValid } = testInstance.getInstance().state;
|
||||
expect(recoveryKeyValid).toBe(true);
|
||||
});
|
||||
|
@ -65,17 +66,20 @@ describe("AccessSecretStorageDialog", function() {
|
|||
);
|
||||
const e = { target: { value: "a" } };
|
||||
stubClient();
|
||||
MatrixClientPeg.get().isValidRecoveryKey = () => true;
|
||||
MatrixClientPeg.get().keyBackupKeyFromRecoveryKey = () => {
|
||||
throw new Error("that's no key");
|
||||
};
|
||||
testInstance.getInstance()._onRecoveryKeyChange(e);
|
||||
await testInstance.getInstance()._onRecoveryKeyNext({ preventDefault: () => {} });
|
||||
const { keyMatches } = testInstance.getInstance().state;
|
||||
expect(keyMatches).toBe(false);
|
||||
// force a validation now because it debounces
|
||||
await testInstance.getInstance()._validateRecoveryKey();
|
||||
|
||||
const { recoveryKeyValid, recoveryKeyCorrect } = testInstance.getInstance().state;
|
||||
expect(recoveryKeyValid).toBe(false);
|
||||
expect(recoveryKeyCorrect).toBe(false);
|
||||
const notification = testInstance.root.findByProps({
|
||||
className: "mx_AccessSecretStorageDialog_keyStatus",
|
||||
className: "mx_AccessSecretStorageDialog_recoveryKeyFeedback mx_AccessSecretStorageDialog_recoveryKeyFeedback_invalid",
|
||||
});
|
||||
expect(notification.props.children).toEqual(
|
||||
["\uD83D\uDC4E ", "Unable to access secret storage. Please verify that you " +
|
||||
"entered the correct recovery key."]);
|
||||
expect(notification.props.children).toEqual("Invalid Recovery Key");
|
||||
done();
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue