clean up finally

This commit is contained in:
Leo Horie 2015-12-20 09:29:12 -05:00
parent ac5810ccbd
commit ae60c96a69

View file

@ -3952,35 +3952,6 @@ function testMithril(mock) {
mock.XMLHttpRequest.$instances.pop().onreadystatechange()
return prop().message === "error occurred" && error().message === "error occurred"
})
test(function() {
// Data returned by then() functions propagate to finally().
var data = m.prop("");
var prop = m.request({method: "GET", url: "test"}).then(function() {return "foo"})["finally"](data)
mock.XMLHttpRequest.$instances.pop().onreadystatechange()
return prop() === "foo" && data() === "foo"
})
test(function() {
// Data returned by finally() functions do *not* propagate to next promise.
var data = m.prop("");
var prop = m.request({method: "GET", url: "test"}).then(function() {return "foo"})["finally"](function() {return "bar"}).then(data)
mock.XMLHttpRequest.$instances.pop().onreadystatechange()
return prop() === "foo" && data() === "foo"
})
test(function() {
// Errors thrown in finally() can be caught by next promise.
var error = m.prop("no error")
var prop = m.request({method: "GET", url: "test"}).then(function() {return "foo"})["finally"](function() {throw new Error("error occurred")})["catch"](error)
mock.XMLHttpRequest.$instances.pop().onreadystatechange()
return prop().message === "error occurred" && error().message === "error occurred"
})
test(function() {
// Promise finally() method occurrs after catch().
var error = m.prop("no error")
var lastly = function() { error("lastly") };
var prop = m.request({method: "GET", url: "test", deserialize: function() {throw new Error("error occurred")}})["catch"](error)["finally"](lastly)
mock.XMLHttpRequest.$instances.pop().onreadystatechange()
return prop().message === "error occurred" && error() === "lastly"
})
test(function() {
var error = m.prop("no error"), exception
var prop = m.request({method: "GET", url: "test", deserialize: function() {throw new TypeError("error occurred")}}).then(null, error)