Skip to content

Commit 1a56d5f

Browse files
0x-r4bbitiurimatias
authored andcommitted
fix(utils/testing): ensure API mock works with req.params and method chaining
1 parent 62a2291 commit 1a56d5f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/utils/testing/src/plugin.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,22 @@ class PluginsMock {
147147
const apiFn = this.plugins.plugin.apiCalls[index];
148148
assert(apiFn, `API call for '${method} ${endpoint}' wanted, but not registered`);
149149

150-
let req;
150+
let req = {};
151151
if (["GET", "DELETE"].includes(method.toUpperCase())) {
152-
req = {
153-
query: params
154-
};
152+
if (params && params.params) {
153+
req.params = params.params;
154+
}
155+
req.query = params;
155156
} else {
156157
req = {
157158
body: params
158159
};
159160
}
160161
const resp = {
161-
send: sinon.spy(),
162-
status: sinon.spy()
162+
send: sinon.spy()
163163
};
164-
apiFn(req, resp);
164+
165+
resp.status = sinon.fake.returns(resp);
165166
return resp;
166167
}
167168
}

0 commit comments

Comments
 (0)