mirror of https://github.com/embarklabs/embark.git
fix(utils/testing): ensure API mock works with `req.params` and method chaining
This commit is contained in:
parent
62a229198b
commit
1a56d5f792
|
@ -147,21 +147,22 @@ class PluginsMock {
|
|||
const apiFn = this.plugins.plugin.apiCalls[index];
|
||||
assert(apiFn, `API call for '${method} ${endpoint}' wanted, but not registered`);
|
||||
|
||||
let req;
|
||||
let req = {};
|
||||
if (["GET", "DELETE"].includes(method.toUpperCase())) {
|
||||
req = {
|
||||
query: params
|
||||
};
|
||||
if (params && params.params) {
|
||||
req.params = params.params;
|
||||
}
|
||||
req.query = params;
|
||||
} else {
|
||||
req = {
|
||||
body: params
|
||||
};
|
||||
}
|
||||
const resp = {
|
||||
send: sinon.spy(),
|
||||
status: sinon.spy()
|
||||
send: sinon.spy()
|
||||
};
|
||||
apiFn(req, resp);
|
||||
|
||||
resp.status = sinon.fake.returns(resp);
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue