All files / server/test generic.js

100% Statements 11/11
100% Branches 4/4
100% Functions 2/2
100% Lines 10/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 1529x   144x 144x 144x 144x 144x 12x 12x     144x 144x    
const normalize = require('./normalize');
 
module.exports = (app, request) => async (method, path, options) => {
  const res = await request(normalize(method, path, app.options.port, options));
  res.method = res.request.method;
  res.status = res.statusCode;
  if (/application\/json/.test(res.headers['content-type']) && typeof res.body === 'string') {
    res.rawBody = res.body;
    res.body = JSON.parse(res.body);
  }
  // console.log(app);
  res.ctx = app;
  return res;
};