summaryrefslogtreecommitdiffhomepage
path: root/test/helpers
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2018-06-14 15:52:27 +0200
committerAndrej Mihajlov <and@mullvad.net>2018-06-20 15:36:17 +0200
commit4ccf1179e6135ec2f8137143d9454a100bccd65f (patch)
treefa3171d967351ec052db5c4fc185894ed259a4c3 /test/helpers
parent69da56287e82a3dcf1b32dc35e30f312822c657d (diff)
downloadmullvadvpn-4ccf1179e6135ec2f8137143d9454a100bccd65f.tar.xz
mullvadvpn-4ccf1179e6135ec2f8137143d9454a100bccd65f.zip
Remove redundant call for `done` when building IpcChain
Diffstat (limited to 'test/helpers')
-rw-r--r--test/helpers/IpcChain.js22
1 files changed, 9 insertions, 13 deletions
diff --git a/test/helpers/IpcChain.js b/test/helpers/IpcChain.js
index 44a1c7b0d7..cc96986cd3 100644
--- a/test/helpers/IpcChain.js
+++ b/test/helpers/IpcChain.js
@@ -18,14 +18,16 @@ export class IpcChain {
}
require<R>(ipcCall: string): StepBuilder<R> {
+ const builder = new StepBuilder(ipcCall);
this._expectedCalls.push(ipcCall);
- return new StepBuilder(ipcCall, this._addStep.bind(this));
+ this._addStep(builder);
+
+ return builder;
}
_addStep<R>(step: StepBuilder<R>) {
- const me = this;
- this._mockIpc[step.ipcCall] = function() {
- return new Promise((r) => me._stepPromiseCallback(step, r, arguments));
+ this._mockIpc[step.ipcCall] = (...args: Array<mixed>) => {
+ return new Promise((r) => this._stepPromiseCallback(step, r, args));
};
}
@@ -80,16 +82,14 @@ export class IpcChain {
class StepBuilder<R> {
ipcCall: string;
- inputValidation: ?() => void;
+ inputValidation: ?(...args: Array<mixed>) => void;
returnValue: ?R;
- _cb: (StepBuilder<R>) => void;
- constructor(ipcCall: string, cb: (StepBuilder<R>) => void) {
+ constructor(ipcCall: string) {
this.ipcCall = ipcCall;
- this._cb = cb;
}
- withInputValidation(iv: () => void): this {
+ withInputValidation(iv: (...args: Array<mixed>) => void): this {
this.inputValidation = iv;
return this;
}
@@ -98,8 +98,4 @@ class StepBuilder<R> {
this.returnValue = rv;
return this;
}
-
- done() {
- this._cb(this);
- }
}