Skip to content

Commit

Permalink
Merge c5cbcd8 into 96137f3
Browse files Browse the repository at this point in the history
  • Loading branch information
fheft committed Nov 5, 2019
2 parents 96137f3 + c5cbcd8 commit 36770b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/batteries.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ effector(
for (let name in headers) {
xhr.setRequestHeader(name, headers[name]);
}
xhr.onload = xhr.onerror = function() {
xhr.onloadend = function() {
switch (this.status) {
case STATUS_OK:
case STATUS_CREATED:
Expand Down
8 changes: 4 additions & 4 deletions src/batteries.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe("xhr effect", () => {
const xhr = xhrs[0];
[200, 201, 202, 204, 206, 304].forEach(status => {
trigger.mockClear();
xhr.onload.call({
xhr.onloadend.call({
status: status,
statusText: "${status}",
response: "response",
Expand All @@ -121,7 +121,7 @@ describe("xhr effect", () => {
statusText: "Server error",
response: "response",
};
xhr.onload.call(response);
xhr.onloadend.call(response);
expect(trigger).toHaveBeenCalledTimes(1);
expect(trigger).toHaveBeenCalledWith("error", "foo", response);
});
Expand All @@ -134,7 +134,7 @@ describe("xhr effect", () => {
statusText: "OK",
response: "response",
};
xhr.onload.call(response);
xhr.onloadend.call(response);
expect(trigger).not.toHaveBeenCalled();
});
it("ignores errors if onError is unset", () => {
Expand All @@ -146,7 +146,7 @@ describe("xhr effect", () => {
statusText: "Server error",
response: "response",
};
xhr.onload.call(response);
xhr.onloadend.call(response);
expect(trigger).not.toHaveBeenCalled();
});
});

0 comments on commit 36770b6

Please sign in to comment.