テスト環境でsuperagentとjasmine-ajaxを使用しています (カルマとジャスミン アダプター)。
スーパーエージェントが処理する応答をモックしようとすると、応答ヘッダーの大文字と小文字の区別に関する問題に気付きました。
テスト コード:
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
});
});
superagent.js の行 ~695 には次のものがあります。
this.header['content-type'] = this.xhr.getResponseHeader('content-type');
mock-ajax.js の行 ~175 には
this.responseHeaders = response.responseHeaders ||
{"Content-type": response.contentType || "application/json" };
そのため、明らかにそれぞれのライブラリ内で大文字と小文字に矛盾がありますが、仕様によると、私が行ったすべての調査によると、このフィールドは大文字と小文字を区別しません。PhantomJS の問題かと思い、Chrome も試してみましたが、同じ問題が発生します。
任意の洞察をいただければ幸いです。