I'm using superagent and jasmine-ajax in my testing environment (karma with jasmine adapter).
I noticed an issue pertaining to case-sensitivity on the response headers when trying to mock responses that superagent will then handle.
Testing code:
it('should parse the response as json', function() {
var response = '{ "foo" : "bar" }';
superagent.get('/some/url', function(
expect(response.body).toEqual({ foo: "bar" });
});
jasmine.Ajax.requests.mostRecent().response({
status: 200,
// uncomment following line to make this test pass
// responseHeaders: { "content-type" : "application/json" },
responseText: response
});
});
In superagent.js line ~695 has:
this.header['content-type'] = this.xhr.getResponseHeader('content-type');
In mock-ajax.js line ~175 has
this.responseHeaders = response.responseHeaders ||
{"Content-type": response.contentType || "application/json" };
So, obviously within each respective library, there is a discrepancy with casing, but, according to spec, all the research I've done says that this field is case-insensitive. I thought that it might be an issue with PhantomJS, but I just tried using Chrome as well, but the same issue is present.
Any insight would be appreciated.