summaryrefslogtreecommitdiffhomepage
path: root/test/helpers/IpcChain.js
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-10-13 11:31:57 +0200
committerErik Larkö <erik@mullvad.net>2017-10-13 11:31:57 +0200
commit992f7946dbe9004d88a331b97ea9e030701599ea (patch)
tree858ef774e0751435f2b039af846cef4d29c37a0c /test/helpers/IpcChain.js
parent8f5c5aa9a433a65d8a7f6f6d8e4211f5a82068f5 (diff)
downloadmullvadvpn-992f7946dbe9004d88a331b97ea9e030701599ea.tar.xz
mullvadvpn-992f7946dbe9004d88a331b97ea9e030701599ea.zip
Move the auth flow into backend.js and write tests
Diffstat (limited to 'test/helpers/IpcChain.js')
-rw-r--r--test/helpers/IpcChain.js19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/helpers/IpcChain.js b/test/helpers/IpcChain.js
index a7916e1e9f..a62626a6a6 100644
--- a/test/helpers/IpcChain.js
+++ b/test/helpers/IpcChain.js
@@ -8,11 +8,13 @@ export class IpcChain {
_recordedCalls: Array<string>;
_mockIpc: {};
_done: (*) => void;
+ _aborted: boolean;
constructor(mockIpc: {}) {
this._expectedCalls = [];
this._recordedCalls = [];
this._mockIpc = mockIpc;
+ this._aborted = false;
}
require(ipcCall: string): StepBuilder {
@@ -28,10 +30,21 @@ export class IpcChain {
}
_stepPromiseCallback(step, resolve, args) {
+ if (this._aborted) {
+ return;
+ }
+
this._registerCall(step.ipcCall);
if (step.inputValidation) {
- failFast(() => step.inputValidation(...args), this._done);
+ const failedInputValidation = failFast(() => {
+ step.inputValidation(...args);
+ }, this._done);
+
+ if (failedInputValidation) {
+ this._abort();
+ return;
+ }
}
if (this._isLastCall()) {
@@ -41,6 +54,10 @@ export class IpcChain {
resolve(step.returnValue);
}
+ _abort() {
+ this._aborted = true;
+ }
+
_isLastCall(): boolean {
return this._recordedCalls.length === this._expectedCalls.length;
}