Merge pull request #94 from tomalec/andReturn_responseHeaders
Add `responseHeaders` to `andReturn` s options
This commit is contained in:
commit
e2fd48f512
@ -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) {
|
||||
|
@ -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});
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user