summaryrefslogtreecommitdiff
path: root/test/parallel/test-promises-unhandled-rejections.js
diff options
context:
space:
mode:
authorMichaël Zasso <mic.besace@gmail.com>2016-01-13 21:42:45 +0100
committerRoman Reiss <me@silverwind.io>2016-01-13 23:16:17 +0100
commitd1aabd626428cec65e5f54c04d9e3446d1e4d3b7 (patch)
tree9a4d4de19204b8b50d496dd6046a897f107bcf4d /test/parallel/test-promises-unhandled-rejections.js
parentec8e0ae697d96c417bda0bbe5be9712cf5923b1f (diff)
downloadandroid-node-v8-d1aabd626428cec65e5f54c04d9e3446d1e4d3b7.tar.gz
android-node-v8-d1aabd626428cec65e5f54c04d9e3446d1e4d3b7.tar.bz2
android-node-v8-d1aabd626428cec65e5f54c04d9e3446d1e4d3b7.zip
test: fix style issues after eslint update
Replace var keyword with const or let. PR-URL: https://github.com/nodejs/io.js/pull/2286 Reviewed-By: Roman Reiss <me@silverwind.io>
Diffstat (limited to 'test/parallel/test-promises-unhandled-rejections.js')
-rw-r--r--test/parallel/test-promises-unhandled-rejections.js168
1 files changed, 90 insertions, 78 deletions
diff --git a/test/parallel/test-promises-unhandled-rejections.js b/test/parallel/test-promises-unhandled-rejections.js
index 5e7739daa5..8345096445 100644
--- a/test/parallel/test-promises-unhandled-rejections.js
+++ b/test/parallel/test-promises-unhandled-rejections.js
@@ -234,23 +234,27 @@ asyncTest('When re-throwing new errors in a promise catch, only the re-thrown' +
var promise2;
});
-asyncTest('unhandledRejection should not be triggered if a promise catch is' +
- ' attached synchronously upon the promise\'s creation',
- function(done) {
- var e = new Error();
- onUnhandledFail(done);
- Promise.reject(e).then(common.fail, function() {});
-});
-
-asyncTest('unhandledRejection should not be triggered if a promise catch is' +
- ' attached synchronously upon the promise\'s creation',
- function(done) {
- var e = new Error();
- onUnhandledFail(done);
- new Promise(function(_, reject) {
- reject(e);
- }).then(common.fail, function() {});
-});
+asyncTest(
+ 'unhandledRejection should not be triggered if a promise catch is' +
+ ' attached synchronously upon the promise\'s creation',
+ function(done) {
+ var e = new Error();
+ onUnhandledFail(done);
+ Promise.reject(e).then(common.fail, function() {});
+ }
+);
+
+asyncTest(
+ 'unhandledRejection should not be triggered if a promise catch is' +
+ ' attached synchronously upon the promise\'s creation',
+ function(done) {
+ var e = new Error();
+ onUnhandledFail(done);
+ new Promise(function(_, reject) {
+ reject(e);
+ }).then(common.fail, function() {});
+ }
+);
asyncTest('Attaching a promise catch in a process.nextTick is soon enough to' +
' prevent unhandledRejection', function(done) {
@@ -360,19 +364,21 @@ asyncTest('A rejected promise derived from throwing in a fulfillment handler' +
});
});
-asyncTest('A rejected promise derived from returning a synchronously-rejected' +
- ' promise in a fulfillment handler does trigger unhandledRejection',
- function(done) {
- var e = new Error();
- var _promise;
- onUnhandledSucceed(done, function(reason, promise) {
- assert.strictEqual(e, reason);
- assert.strictEqual(_promise, promise);
- });
- _promise = Promise.resolve().then(function() {
- return Promise.reject(e);
- });
-});
+asyncTest(
+ 'A rejected promise derived from returning a synchronously-rejected' +
+ ' promise in a fulfillment handler does trigger unhandledRejection',
+ function(done) {
+ var e = new Error();
+ var _promise;
+ onUnhandledSucceed(done, function(reason, promise) {
+ assert.strictEqual(e, reason);
+ assert.strictEqual(_promise, promise);
+ });
+ _promise = Promise.resolve().then(function() {
+ return Promise.reject(e);
+ });
+ }
+);
// Combinations with Promise.all
asyncTest('Catching the Promise.all() of a collection that includes a' +
@@ -382,21 +388,23 @@ asyncTest('Catching the Promise.all() of a collection that includes a' +
Promise.all([Promise.reject(e)]).then(common.fail, function() {});
});
-asyncTest('Catching the Promise.all() of a collection that includes a ' +
- 'nextTick-async rejected promise prevents unhandledRejection',
- function(done) {
- var e = new Error();
- onUnhandledFail(done);
- var p = new Promise(function(_, reject) {
+asyncTest(
+ 'Catching the Promise.all() of a collection that includes a ' +
+ 'nextTick-async rejected promise prevents unhandledRejection',
+ function(done) {
+ var e = new Error();
+ onUnhandledFail(done);
+ var p = new Promise(function(_, reject) {
+ process.nextTick(function() {
+ reject(e);
+ });
+ });
+ p = Promise.all([p]);
process.nextTick(function() {
- reject(e);
+ p.then(common.fail, function() {});
});
- });
- p = Promise.all([p]);
- process.nextTick(function() {
- p.then(common.fail, function() {});
- });
-});
+ }
+);
asyncTest('Failing to catch the Promise.all() of a collection that includes' +
' a rejected promise triggers unhandledRejection for the returned' +
@@ -513,26 +521,28 @@ asyncTest('Waiting for some combination of promise microtasks + ' +
});
});
-asyncTest('Waiting for some combination of promise microtasks +' +
- ' process.nextTick to attach a catch handler is still soon enough' +
- ' to prevent unhandledRejection: inside setImmediate',
- function(done) {
- var e = new Error();
- onUnhandledFail(done);
+asyncTest(
+ 'Waiting for some combination of promise microtasks +' +
+ ' process.nextTick to attach a catch handler is still soon enough' +
+ ' to prevent unhandledRejection: inside setImmediate',
+ function(done) {
+ var e = new Error();
+ onUnhandledFail(done);
- setImmediate(function() {
- var a = Promise.reject(e);
- Promise.resolve().then(function() {
- process.nextTick(function() {
- Promise.resolve().then(function() {
- process.nextTick(function() {
- a.catch(function() {});
+ setImmediate(function() {
+ var a = Promise.reject(e);
+ Promise.resolve().then(function() {
+ process.nextTick(function() {
+ Promise.resolve().then(function() {
+ process.nextTick(function() {
+ a.catch(function() {});
+ });
});
});
});
});
- });
-});
+ }
+);
asyncTest('Waiting for some combination of promise microtasks +' +
' process.nextTick to attach a catch handler is still soon enough' +
@@ -612,28 +622,30 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' +
});
});
-asyncTest('Promise unhandledRejection handler does not interfere with domain' +
- ' error handlers being given exceptions thrown from nextTick.',
- function(done) {
- var d = domain.create();
- var domainReceivedError;
- d.on('error', function(e) {
- domainReceivedError = e;
- });
- d.run(function() {
- var e = new Error('error');
- var domainError = new Error('domain error');
- onUnhandledSucceed(done, function(reason, promise) {
- assert.strictEqual(reason, e);
- assert.strictEqual(domainReceivedError, domainError);
- d.dispose();
+asyncTest(
+ 'Promise unhandledRejection handler does not interfere with domain' +
+ ' error handlers being given exceptions thrown from nextTick.',
+ function(done) {
+ var d = domain.create();
+ var domainReceivedError;
+ d.on('error', function(e) {
+ domainReceivedError = e;
});
- Promise.reject(e);
- process.nextTick(function() {
- throw domainError;
+ d.run(function() {
+ var e = new Error('error');
+ var domainError = new Error('domain error');
+ onUnhandledSucceed(done, function(reason, promise) {
+ assert.strictEqual(reason, e);
+ assert.strictEqual(domainReceivedError, domainError);
+ d.dispose();
+ });
+ Promise.reject(e);
+ process.nextTick(function() {
+ throw domainError;
+ });
});
- });
-});
+ }
+);
asyncTest('nextTick is immediately scheduled when called inside an event' +
' handler', function(done) {