Skip to content

Commit

Permalink
Merge pull request #150 from mAAdhaTTah/add-responseURL-support
Browse files Browse the repository at this point in the history
Add support for responseURL to fakeXHR
  • Loading branch information
fatso83 authored Feb 18, 2021
2 parents f7ab6ec + c725e62 commit 805200b
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 805200b

Please sign in to comment.