mirror of https://github.com/vector-im/riot-web
lint
parent
a677780889
commit
9a5663056d
|
@ -22,46 +22,46 @@ import { stubClient } from '../../../test-utils';
|
||||||
|
|
||||||
const AccessSecretStorageDialog = sdk.getComponent("dialogs.secretstorage.AccessSecretStorageDialog");
|
const AccessSecretStorageDialog = sdk.getComponent("dialogs.secretstorage.AccessSecretStorageDialog");
|
||||||
|
|
||||||
describe("AccessSecretStorageDialog", function () {
|
describe("AccessSecretStorageDialog", function() {
|
||||||
it("Closes the dialog if _onRecoveryKeyNext is called with a valid key", (done) => {
|
it("Closes the dialog if _onRecoveryKeyNext is called with a valid key", (done) => {
|
||||||
const testInstance = TestRenderer.create(
|
const testInstance = TestRenderer.create(
|
||||||
<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);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Considers a valid key to be valid", function () {
|
it("Considers a valid key to be valid", 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);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Notifies the user if they input an invalid recovery key", async function (done) {
|
it("Notifies the user if they input an invalid recovery key", async function(done) {
|
||||||
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,10 +76,10 @@ 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) {
|
||||||
const testInstance = TestRenderer.create(
|
const testInstance = TestRenderer.create(
|
||||||
<AccessSecretStorageDialog
|
<AccessSecretStorageDialog
|
||||||
checkPrivateKey={() => false}
|
checkPrivateKey={() => false}
|
||||||
|
@ -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",
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue