Add tests for simulating empty body response#182
Add tests for simulating empty body response#182fraziern wants to merge 1 commit intopretenderjs:masterfrom
Conversation
|
@fraziern can you verify that this is what actually happens? My understanding was that XHR responses for no bodies had null (or maybe undefined) response texts, not empty strings? |
|
@trek good question. I did some testing and it looks like request.response is undefined, while request.responseText === ''. So adding If this is causing issues elsewhere, I can take a look, or I can just add the request.response check to the tests. |
|
Weird, I just did a small test: and both |
|
I was testing with the existing test framework, rather than a separate setup. I was able to replicate your results in Chrome. However, if I change the responseType to Server: Client: Taking a look at the XMLHttpRequest spec, I think this is the correct result:
So I think where that leaves us, is we'd want |
ya, we should mimic spec behavior |
For issue #123 - it appears that null and undefined body responses are already handled OK by pretender. I've added tests for this, and an extra line in the README per the issue comments.