From 0b84a3f39f67e170fe676819879fd01ff829fe6c Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Wed, 7 Dec 2016 11:58:30 -0500 Subject: [PATCH] fix tests from #1470 --- promise/tests/test-promise.js | 25 ++++++++++++++----------- request/tests/index.html | 1 + request/tests/test-request.js | 28 ++++++++++++++++------------ 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/promise/tests/test-promise.js b/promise/tests/test-promise.js index 802c9f93..aa3a1bd9 100644 --- a/promise/tests/test-promise.js +++ b/promise/tests/test-promise.js @@ -405,20 +405,23 @@ o.spec("promise", function() { }) o("triggers all branched rejection handlers upon rejection", function(done) { var promise = Promise.reject() - var then = o.spy() - var catch1 = o.spy() - var catch2 = o.spy() - var catch3 = o.spy() + var then = o.spy() + var catch1 = o.spy() + var catch2 = o.spy() + var catch3 = o.spy() promise.catch(catch1) - promise.then(then, catch2).catch(catch3) + promise.then(then, catch2) + promise.then(then).catch(catch3) - promise.then(null, function(){ - o(catch1.callCount).equals(1, "first branch catch triggers") - o(then.callCount).equals(0, "second branch then resolution handler doesn't trigger") - o(catch2.callCount).equals(1, "second branch then rejection handler triggers") - o(catch3.callCount).equals(1, "second branch subseqent catch triggers") - done() + 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() + }) }) }) o("does not absorb resolved promise via static rejector", function(done) { diff --git a/request/tests/index.html b/request/tests/index.html index e30c178e..179c66a1 100644 --- a/request/tests/index.html +++ b/request/tests/index.html @@ -6,6 +6,7 @@ + diff --git a/request/tests/test-request.js b/request/tests/test-request.js index 652f63bc..86643e95 100644 --- a/request/tests/test-request.js +++ b/request/tests/test-request.js @@ -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") @@ -384,21 +385,24 @@ o.spec("xhr", function() { } }) var request = xhr({method: "GET", url: "/item"}) - var then = o.spy() - var catch1 = o.spy() - var catch2 = o.spy() - var catch3 = o.spy() + var then = o.spy() + var catch1 = o.spy() + var catch2 = o.spy() + var catch3 = o.spy() request.catch(catch1) - request.then(then, catch2).catch(catch3) + request.then(then, catch2) + request.then(then).catch(catch3) - setTimeout(function(){ - o(catch1.callCount).equals(1, "first branch catch triggers") - o(then.callCount).equals(0, "second branch then resolution handler doesn't trigger") - o(catch2.callCount).equals(1, "second branch then rejection handler triggers") - o(catch3.callCount).equals(1, "second branch subseqent catch triggers") - done() - }, 10) + 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() + }) + }) }) }) })