Track XHR replacements correctly (#2455)

* Track XHR replacements correctly

Fixes #2439

* Update docs [skip ci]
This commit is contained in:
Isiah Meadows 2019-07-05 19:50:51 -04:00 committed by GitHub
parent 7eee730c29
commit 8eed896859
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 134 additions and 35 deletions

View file

@ -61,6 +61,23 @@ o.spec("xhrMock", function() {
}
xhr.send("a=b")
})
o("passes event to onreadystatechange", function(done) {
$window.$defineRoutes({
"GET /item": function(request) {
o(request.url).equals("/item")
return {status: 200, responseText: "test"}
}
})
var xhr = new $window.XMLHttpRequest()
xhr.open("GET", "/item")
xhr.onreadystatechange = function(ev) {
o(ev.target).equals(xhr)
if (xhr.readyState === 4) {
done()
}
}
xhr.send()
})
o("handles routing error", function(done) {
var xhr = new $window.XMLHttpRequest()
xhr.open("GET", "/nonexistent")