Call onreadystatechange in handler

This commit is contained in:
impinball 2015-12-16 13:38:09 -05:00
parent c21566366e
commit 11f05e3180
3 changed files with 4 additions and 6 deletions

View file

@ -232,6 +232,7 @@ this.mock = (function (global) {
this.responseText = JSON.stringify(data) this.responseText = JSON.stringify(data)
this.readyState = 4 this.readyState = 4
this.status = status || 200 this.status = status || 200
this.onreadystatechange()
return this return this
} }

View file

@ -648,7 +648,7 @@ describe("m.mount()", function () {
}) })
function resolveXhr() { function resolveXhr() {
mock.XMLHttpRequest.$instances.pop().$resolve().onreadystatechange() mock.XMLHttpRequest.$instances.pop().$resolve()
mock.requestAnimationFrame.$resolve() mock.requestAnimationFrame.$resolve()
} }

View file

@ -5,7 +5,6 @@ describe("m.request()", function () {
function resolve() { function resolve() {
var xhr = mock.XMLHttpRequest.$instances.pop() var xhr = mock.XMLHttpRequest.$instances.pop()
xhr.$resolve.apply(xhr, arguments) xhr.$resolve.apply(xhr, arguments)
xhr.onreadystatechange()
return xhr return xhr
} }
@ -182,8 +181,7 @@ describe("m.request()", function () {
data: {foo: 1} data: {foo: 1}
}).then(null, error) }).then(null, error)
var xhr = mock.XMLHttpRequest.$instances.pop() var xhr = mock.XMLHttpRequest.$instances.pop().$resolve()
xhr.onreadystatechange()
expect(xhr.$headers).to.have.property( expect(xhr.$headers).to.have.property(
"Content-Type", "Content-Type",
@ -198,8 +196,7 @@ describe("m.request()", function () {
url: "test" url: "test"
}).then(null, error) }).then(null, error)
var xhr = mock.XMLHttpRequest.$instances.pop() var xhr = mock.XMLHttpRequest.$instances.pop().$resolve()
xhr.onreadystatechange()
expect(xhr.$headers).to.not.have.property("Content-Type") expect(xhr.$headers).to.not.have.property("Content-Type")
}) })