Archived
2

implemented code coverage

This commit is contained in:
VLE2FE
2020-05-28 11:47:51 +02:00
parent d004a01b69
commit 0ea28fa50a
12 changed files with 79 additions and 18 deletions

View File

@ -39,6 +39,10 @@ export default class TestHelper {
server.close(done);
}
static after(done) {
db.disconnect(done);
}
static request (server, done, options) { // options in form: {method, url, auth: {key/basic: 'name' or 'key'/{name, pass}}, httpStatus, req, res}
let st = supertest(server);
if (options.hasOwnProperty('auth') && options.auth.hasOwnProperty('key')) { // resolve API key
@ -58,6 +62,9 @@ export default class TestHelper {
st = st.delete(options.url)
break;
}
if (options.hasOwnProperty('reqType')) { // request body
st = st.type(options.reqType);
}
if (options.hasOwnProperty('req')) { // request body
st = st.send(options.req);
}