Content-Type Header Not Set in `EndpointRequest.mock`
ranchodeluxe opened this issue · comments
I noticed when writing controller tests for POST
and PUT
that nothing was passing because all the validators failed regardless of the payload I submit. I also did not see a way to override the headers. This led me to discover the following bug. When I get time I'll submit a patch:
EndpointReqeust.mock
method passes Router.prepare
an empty hash
Which makes the Router.parseBody
in poly/fxn
set contentType
to be an empty string
An example of test that fails on the built-in User
model and UserController
:
'use strict';
const Nodal = require('nodal');
class UserControllerTest extends Nodal.mocha.Test {
test(expect) {
it('assert POST returns an HTTP 200', done => {
this.endpoint('/v1/users/').post({"email":"foobar@gmail.com","username":"foobar","password":"foobar"},
(status, headers, body, json) => {
//console.log("[ JSON ]: ", json);
expect(status).to.equal(200);
done();
});
});
}; // test()
}
module.exports = UserControllerTest;