Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content-Type Header Not Set in EndpointRequest.mock #300

Open
ranchodeluxe opened this issue Oct 5, 2016 · 0 comments
Open

Content-Type Header Not Set in EndpointRequest.mock #300

ranchodeluxe opened this issue Oct 5, 2016 · 0 comments

Comments

@ranchodeluxe
Copy link

ranchodeluxe commented Oct 5, 2016

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant