pull/21833/head
Zoe 2020-02-11 12:06:40 +00:00
parent a677780889
commit 9a5663056d
1 changed files with 14 additions and 14 deletions

View File

@ -28,15 +28,15 @@ describe("AccessSecretStorageDialog", function () {
<AccessSecretStorageDialog <AccessSecretStorageDialog
checkPrivateKey={(p) => p && p.recoveryKey && p.recoveryKey == "a"} checkPrivateKey={(p) => p && p.recoveryKey && p.recoveryKey == "a"}
onFinished={(v) => { onFinished={(v) => {
if (v) { done() } if (v) { done(); }
}} }}
/> />,
); );
testInstance.getInstance().setState({ testInstance.getInstance().setState({
recoveryKeyValid: true, recoveryKeyValid: true,
recoveryKey: "a", recoveryKey: "a",
}); });
const e = { preventDefault: () => {} } const e = { preventDefault: () => {} };
testInstance.getInstance()._onRecoveryKeyNext(e); testInstance.getInstance()._onRecoveryKeyNext(e);
}); });
@ -44,14 +44,14 @@ describe("AccessSecretStorageDialog", function () {
const testInstance = TestRenderer.create( const testInstance = TestRenderer.create(
<AccessSecretStorageDialog <AccessSecretStorageDialog
checkPrivateKey={() => true} checkPrivateKey={() => true}
/> />,
); );
const v = "asfd"; const v = "asfd";
const e = { target: { value: v } }; const e = { target: { value: v } };
stubClient(); stubClient();
MatrixClientPeg.get().isValidRecoveryKey = function(k) { MatrixClientPeg.get().isValidRecoveryKey = function(k) {
return k == v; return k == v;
} };
testInstance.getInstance()._onRecoveryKeyChange(e); testInstance.getInstance()._onRecoveryKeyChange(e);
const { recoveryKeyValid } = testInstance.getInstance().state; const { recoveryKeyValid } = testInstance.getInstance().state;
expect(recoveryKeyValid).toBe(true); expect(recoveryKeyValid).toBe(true);
@ -61,7 +61,7 @@ describe("AccessSecretStorageDialog", function () {
const testInstance = TestRenderer.create( const testInstance = TestRenderer.create(
<AccessSecretStorageDialog <AccessSecretStorageDialog
checkPrivateKey={async () => false} checkPrivateKey={async () => false}
/> />,
); );
const e = { target: { value: "a" } }; const e = { target: { value: "a" } };
stubClient(); stubClient();
@ -76,7 +76,7 @@ describe("AccessSecretStorageDialog", function () {
expect(notification.props.children).toEqual( expect(notification.props.children).toEqual(
["\uD83D\uDC4E ", "Unable to access secret storage. Please verify that you " + ["\uD83D\uDC4E ", "Unable to access secret storage. Please verify that you " +
"entered the correct recovery key."]); "entered the correct recovery key."]);
done() done();
}); });
it("Notifies the user if they input an invalid passphrase", async function(done) { it("Notifies the user if they input an invalid passphrase", async function(done) {
@ -88,13 +88,13 @@ describe("AccessSecretStorageDialog", function () {
salt: 'nonempty', salt: 'nonempty',
iterations: 2, iterations: 2,
} } } } } }
/> />,
); );
const e = { target: { value: "a" } }; const e = { target: { value: "a" } };
stubClient(); stubClient();
MatrixClientPeg.get().isValidRecoveryKey = () => false; MatrixClientPeg.get().isValidRecoveryKey = () => false;
testInstance.getInstance()._onPassPhraseChange(e); testInstance.getInstance()._onPassPhraseChange(e);
await testInstance.getInstance()._onPassPhraseNext({ preventDefault: () => {} }) await testInstance.getInstance()._onPassPhraseNext({ preventDefault: () => {} });
const notification = testInstance.root.findByProps({ const notification = testInstance.root.findByProps({
className: "mx_AccessSecretStorageDialog_keyStatus", className: "mx_AccessSecretStorageDialog_keyStatus",
}); });