Skip to content

Commit

Permalink
Add support for responseURL to fakeXHR
Browse files Browse the repository at this point in the history
  • Loading branch information
mAAdhaTTah committed Mar 28, 2020
1 parent b7bc79c commit c725e62
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/fake-xhr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,8 @@ function fakeXMLHttpRequestFor(globalScope) {
this.setStatus(status);
this.setResponseHeaders(headers || {});
this.setResponseBody(body || "");

this.responseURL = this.url;
},

uploadProgress: function uploadProgress(progressEventRaw) {
Expand Down
20 changes: 20 additions & 0 deletions lib/fake-xhr/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1907,6 +1907,26 @@ describe("FakeXMLHttpRequest", function() {
});
});

describe(".responseURL", function() {
beforeEach(function() {
this.xhr = new FakeXMLHttpRequest();
});

it("should set responseURL after response", function() {
this.xhr.open("GET", "/");

assert.isUndefined(this.xhr.responseURL);

this.xhr.send();

assert.isUndefined(this.xhr.responseURL);

this.xhr.respond(200, {}, "");

assert.equals(this.xhr.responseURL, "/");
});
});

describe("stub XHR", function() {
beforeEach(fakeXhrSetUp);
afterEach(fakeXhrTearDown);
Expand Down

0 comments on commit c725e62

Please sign in to comment.