Merge branch 'rewrite' into array-isArray

This commit is contained in:
Barney Carroll 2016-12-16 10:51:39 +00:00
commit aa72f87408
27 changed files with 1172 additions and 529 deletions

View file

@ -18,7 +18,7 @@ module.exports = function($window, Promise) {
var next = then.apply(promise, arguments)
next.then(complete, function(e) {
complete()
throw e
if (count === 0) throw e
})
return finalize(next)
}

View file

@ -6,6 +6,7 @@
<body>
<script src="../../module/module.js"></script>
<script src="../../ospec/ospec.js"></script>
<script src="../../test-utils/callAsync.js"></script>
<script src="../../querystring/parse.js"></script>
<script src="../../test-utils/parseURL.js"></script>
<script src="../../test-utils/callAsync.js"></script>

View file

@ -1,6 +1,7 @@
"use strict"
var o = require("../../ospec/ospec")
var callAsync = require("../../test-utils/callAsync")
var xhrMock = require("../../test-utils/xhrMock")
var Request = require("../../request/request")
var Promise = require("../../promise/promise")
@ -336,7 +337,7 @@ o.spec("xhr", function() {
}
})
var promise = xhr("/item", {background: true}).then(function() {})
setTimeout(function() {
o(complete.callCount).equals(0)
done()
@ -377,5 +378,31 @@ o.spec("xhr", function() {
o(e.message).equals("error")
}).then(done)
})
o("triggers all branched catches upon rejection", function(done) {
mock.$defineRoutes({
"GET /item": function(request) {
return {status: 500, responseText: "error"}
}
})
var request = xhr({method: "GET", url: "/item"})
var then = o.spy()
var catch1 = o.spy()
var catch2 = o.spy()
var catch3 = o.spy()
request.catch(catch1)
request.then(then, catch2)
request.then(then).catch(catch3)
callAsync(function() {
callAsync(function() {
o(catch1.callCount).equals(1)
o(then.callCount).equals(0)
o(catch2.callCount).equals(1)
o(catch3.callCount).equals(1)
done()
})
})
})
})
})