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
Enable non-object JSON bodies #1282
Conversation
b0ded10
to
4f95428
Compare
body: value | ||
} | ||
request(opts, function (err, resp, body) { | ||
t.equal(err, null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't mind if we have t.deepEqual(value, body)
here just to make sure (and clear) we're parsing back the value correctly. Currently that's not possible because createPostValidator
is returning plain text, and in the case of this test it's checking only for the presence of the content-type
header and if the value was stringified correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the test to do this verification using a new createPostJSONValidator
method that returns a JSON response.
Please see #1281 for more comments regarding this pull request. |
@simov: updated the test |
@apoco can you pull simov@9634268 into your branch? The changes are:
The server returns the value as it is, you was returning object all the time, which does not test the changes you made. Otherwise 👍 from me |
Actually you are implementing only the sending of non |
Updated JSON requests so they can contain bodies that are not objects. For avoid unexpected surprises, JSON `null` values are not sent.
Added test to ensure each type of JSON root object can be sent in a request
Modified JSON request tests so the same value sent in the request is echoed in the test server JSON response.
d12b4e6
to
ce70514
Compare
I rebased and pushed a change so that the test server returns the same body it received in the request as the response. I'm confused how this makes any difference, but I think this is what was asked for. I'm confused because the prior test:
To me, this describes what should be being tested. Am I missing something? |
Exactly, that's why in my last comment in the code I said that I'm ok with the deep equality check in the validator. The reason for returning the original value back to request is exactly the same as the deep equality check on the server. Practically this should be the same, of course, but just for the sake of completeness I though it's logical to have the same deep equality check for the client as well. Anyway looking good to me, except that Travis is failing for some reason. |
Gotcha. Looks like there was a timeout for a proxy test. It doesn't look related to my changes. Maybe there's a flaky test. Is there a way to re-run the tests? Or maybe that failure can be ignored. |
Yep, there is a restart build button, so I just did that - all passing. |
For some reason this change brakes the form option when it's object
Revert changes introduced in #1282
Updated JSON requests so they can contain bodies that are not objects