Merge pull request #94 from tomalec/andReturn_responseHeaders

Add `responseHeaders` to `andReturn` s options
This commit is contained in:
Gregg Van Hove 2015-02-27 16:10:15 -08:00
commit e2fd48f512
3 changed files with 11 additions and 0 deletions

View File

@ -466,6 +466,7 @@ getJasmineRequireObj().AjaxRequestStub = function() {
this.contentType = options.contentType;
this.response = options.response;
this.responseText = options.responseText;
this.responseHeaders = options.responseHeaders;
};
this.matches = function(fullUrl, data, method) {

View File

@ -51,6 +51,15 @@ describe("Webmock style mocking", function() {
expect(response.status).toEqual(200);
});
it("should set the responseHeaders", function() {
mockAjax.stubRequest("http://example.com/someApi").andReturn({
responseText: "hi!",
responseHeaders: [{name: "X-Custom", value: "header value"}]
});
sendRequest(fakeGlobal);
expect(response.getResponseHeader('X-Custom')).toEqual('header value');
});
describe("with another stub for the same url", function() {
beforeEach(function() {
mockAjax.stubRequest("http://example.com/someApi").andReturn({responseText: "no", status: 403});

View File

@ -22,6 +22,7 @@ getJasmineRequireObj().AjaxRequestStub = function() {
this.contentType = options.contentType;
this.response = options.response;
this.responseText = options.responseText;
this.responseHeaders = options.responseHeaders;
};
this.matches = function(fullUrl, data, method) {