diff --git a/test-deps/mock.js b/test-deps/mock.js index 81304cbe..7c086b96 100644 --- a/test-deps/mock.js +++ b/test-deps/mock.js @@ -232,6 +232,7 @@ this.mock = (function (global) { this.responseText = JSON.stringify(data) this.readyState = 4 this.status = status || 200 + this.onreadystatechange() return this } diff --git a/test/mithril.mount.js b/test/mithril.mount.js index d5f606d9..736f87a1 100644 --- a/test/mithril.mount.js +++ b/test/mithril.mount.js @@ -648,7 +648,7 @@ describe("m.mount()", function () { }) function resolveXhr() { - mock.XMLHttpRequest.$instances.pop().$resolve().onreadystatechange() + mock.XMLHttpRequest.$instances.pop().$resolve() mock.requestAnimationFrame.$resolve() } diff --git a/test/mithril.request.js b/test/mithril.request.js index 945164dc..ed361bf4 100644 --- a/test/mithril.request.js +++ b/test/mithril.request.js @@ -5,7 +5,6 @@ describe("m.request()", function () { function resolve() { var xhr = mock.XMLHttpRequest.$instances.pop() xhr.$resolve.apply(xhr, arguments) - xhr.onreadystatechange() return xhr } @@ -182,8 +181,7 @@ describe("m.request()", function () { data: {foo: 1} }).then(null, error) - var xhr = mock.XMLHttpRequest.$instances.pop() - xhr.onreadystatechange() + var xhr = mock.XMLHttpRequest.$instances.pop().$resolve() expect(xhr.$headers).to.have.property( "Content-Type", @@ -198,8 +196,7 @@ describe("m.request()", function () { url: "test" }).then(null, error) - var xhr = mock.XMLHttpRequest.$instances.pop() - xhr.onreadystatechange() + var xhr = mock.XMLHttpRequest.$instances.pop().$resolve() expect(xhr.$headers).to.not.have.property("Content-Type") })