Skip to content

Commit 68a270e

Browse files
committed
Wrap lines in test-promises-unhandled-rejections
1 parent 1031ce3 commit 68a270e

File tree

1 file changed

+92
-36
lines changed

1 file changed

+92
-36
lines changed

test/parallel/test-promises-unhandled-rejections.js

Lines changed: 92 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable max-len */
21
'use strict';
32
var common = require('../common');
43
var assert = require('assert');
@@ -107,15 +106,17 @@ function onUnhandledFail(done) {
107106
}, 10);
108107
}
109108

110-
asyncTest('synchronously rejected promise should trigger unhandledRejection', function(done) {
109+
asyncTest('synchronously rejected promise should trigger' +
110+
' unhandledRejection', function(done) {
111111
var e = new Error();
112112
onUnhandledSucceed(done, function(reason, promise) {
113113
assert.strictEqual(e, reason);
114114
});
115115
Promise.reject(e);
116116
});
117117

118-
asyncTest('synchronously rejected promise should trigger unhandledRejection', function(done) {
118+
asyncTest('synchronously rejected promise should trigger' +
119+
' unhandledRejection', function(done) {
119120
var e = new Error();
120121
onUnhandledSucceed(done, function(reason, promise) {
121122
assert.strictEqual(e, reason);
@@ -125,7 +126,8 @@ asyncTest('synchronously rejected promise should trigger unhandledRejection', fu
125126
});
126127
});
127128

128-
asyncTest('Promise rejected after setImmediate should trigger unhandledRejection', function(done) {
129+
asyncTest('Promise rejected after setImmediate should trigger' +
130+
' unhandledRejection', function(done) {
129131
var e = new Error();
130132
onUnhandledSucceed(done, function(reason, promise) {
131133
assert.strictEqual(e, reason);
@@ -137,7 +139,8 @@ asyncTest('Promise rejected after setImmediate should trigger unhandledRejection
137139
});
138140
});
139141

140-
asyncTest('Promise rejected after setTimeout(,1) should trigger unhandled rejection', function(done) {
142+
asyncTest('Promise rejected after setTimeout(,1) should trigger' +
143+
' unhandled rejection', function(done) {
141144
var e = new Error();
142145
onUnhandledSucceed(done, function(reason, promise) {
143146
assert.strictEqual(e, reason);
@@ -149,7 +152,8 @@ asyncTest('Promise rejected after setTimeout(,1) should trigger unhandled reject
149152
});
150153
});
151154

152-
asyncTest('Catching a promise rejection after setImmediate is not soon enough to stop unhandledRejection', function(done) {
155+
asyncTest('Catching a promise rejection after setImmediate is not' +
156+
' soon enough to stop unhandledRejection', function(done) {
153157
var e = new Error();
154158
onUnhandledSucceed(done, function(reason, promise) {
155159
assert.strictEqual(e, reason);
@@ -164,7 +168,8 @@ asyncTest('Catching a promise rejection after setImmediate is not soon enough to
164168
});
165169
});
166170

167-
asyncTest('When re-throwing new errors in a promise catch, only the re-thrown error should hit unhandledRejection', function(done) {
171+
asyncTest('When re-throwing new errors in a promise catch, only the' +
172+
' re-thrown error should hit unhandledRejection', function(done) {
168173
var e = new Error();
169174
var e2 = new Error();
170175
onUnhandledSucceed(done, function(reason, promise) {
@@ -177,7 +182,8 @@ asyncTest('When re-throwing new errors in a promise catch, only the re-thrown er
177182
});
178183
});
179184

180-
asyncTest('Test params of unhandledRejection for a synchronously-rejected promise', function(done) {
185+
asyncTest('Test params of unhandledRejection for a synchronously-rejected' +
186+
'promise', function(done) {
181187
var e = new Error();
182188
var e2 = new Error();
183189
onUnhandledSucceed(done, function(reason, promise) {
@@ -187,7 +193,9 @@ asyncTest('Test params of unhandledRejection for a synchronously-rejected promis
187193
var promise = Promise.reject(e);
188194
});
189195

190-
asyncTest('When re-throwing new errors in a promise catch, only the re-thrown error should hit unhandledRejection: original promise rejected async with setTimeout(,1)', function(done) {
196+
asyncTest('When re-throwing new errors in a promise catch, only the ' +
197+
're-thrown error should hit unhandledRejection: original promise' +
198+
' rejected async with setTimeout(,1)', function(done) {
191199
var e = new Error();
192200
var e2 = new Error();
193201
onUnhandledSucceed(done, function(reason, promise) {
@@ -204,7 +212,9 @@ asyncTest('When re-throwing new errors in a promise catch, only the re-thrown er
204212
});
205213
});
206214

207-
asyncTest('When re-throwing new errors in a promise catch, only the re-thrown error should hit unhandledRejection: promise catch attached a process.nextTick after rejection', function(done) {
215+
asyncTest('When re-throwing new errors in a promise catch, only the re-thrown' +
216+
' error should hit unhandledRejection: promise catch attached a' +
217+
' process.nextTick after rejection', function(done) {
208218
var e = new Error();
209219
var e2 = new Error();
210220
onUnhandledSucceed(done, function(reason, promise) {
@@ -225,21 +235,26 @@ asyncTest('When re-throwing new errors in a promise catch, only the re-thrown er
225235
var promise2;
226236
});
227237

228-
asyncTest('unhandledRejection should not be triggered if a promise catch is attached synchronously upon the promise\'s creation', function(done) {
238+
asyncTest('unhandledRejection should not be triggered if a promise catch is' +
239+
' attached synchronously upon the promise\'s creation',
240+
function(done) {
229241
var e = new Error();
230242
onUnhandledFail(done);
231243
Promise.reject(e).then(assert.fail, function() {});
232244
});
233245

234-
asyncTest('unhandledRejection should not be triggered if a promise catch is attached synchronously upon the promise\'s creation', function(done) {
246+
asyncTest('unhandledRejection should not be triggered if a promise catch is' +
247+
' attached synchronously upon the promise\'s creation',
248+
function(done) {
235249
var e = new Error();
236250
onUnhandledFail(done);
237251
new Promise(function(_, reject) {
238252
reject(e);
239253
}).then(assert.fail, function() {});
240254
});
241255

242-
asyncTest('Attaching a promise catch in a process.nextTick is soon enough to prevent unhandledRejection', function(done) {
256+
asyncTest('Attaching a promise catch in a process.nextTick is soon enough to' +
257+
' prevent unhandledRejection', function(done) {
243258
var e = new Error();
244259
onUnhandledFail(done);
245260
var promise = Promise.reject(e);
@@ -248,7 +263,8 @@ asyncTest('Attaching a promise catch in a process.nextTick is soon enough to pre
248263
});
249264
});
250265

251-
asyncTest('Attaching a promise catch in a process.nextTick is soon enough to prevent unhandledRejection', function(done) {
266+
asyncTest('Attaching a promise catch in a process.nextTick is soon enough to' +
267+
' prevent unhandledRejection', function(done) {
252268
var e = new Error();
253269
onUnhandledFail(done);
254270
var promise = new Promise(function(_, reject) {
@@ -260,7 +276,9 @@ asyncTest('Attaching a promise catch in a process.nextTick is soon enough to pre
260276
});
261277

262278
// State adapation tests
263-
asyncTest('catching a promise which is asynchronously rejected (via resolution to an asynchronously-rejected promise) prevents unhandledRejection', function(done) {
279+
asyncTest('catching a promise which is asynchronously rejected (via' +
280+
'resolution to an asynchronously-rejected promise) prevents' +
281+
' unhandledRejection', function(done) {
264282
var e = new Error();
265283
onUnhandledFail(done);
266284
Promise.resolve().then(function() {
@@ -274,7 +292,8 @@ asyncTest('catching a promise which is asynchronously rejected (via resolution t
274292
});
275293
});
276294

277-
asyncTest('Catching a rejected promise derived from throwing in a fulfillment handler prevents unhandledRejection', function(done) {
295+
asyncTest('Catching a rejected promise derived from throwing in a' +
296+
' fulfillment handler prevents unhandledRejection', function(done) {
278297
var e = new Error();
279298
onUnhandledFail(done);
280299
Promise.resolve().then(function() {
@@ -284,7 +303,9 @@ asyncTest('Catching a rejected promise derived from throwing in a fulfillment ha
284303
});
285304
});
286305

287-
asyncTest('Catching a rejected promise derived from returning a synchronously-rejected promise in a fulfillment handler prevents unhandledRejection', function(done) {
306+
asyncTest('Catching a rejected promise derived from returning a' +
307+
' synchronously-rejected promise in a fulfillment handler' +
308+
' prevents unhandledRejection', function(done) {
288309
var e = new Error();
289310
onUnhandledFail(done);
290311
Promise.resolve().then(function() {
@@ -294,7 +315,9 @@ asyncTest('Catching a rejected promise derived from returning a synchronously-re
294315
});
295316
});
296317

297-
asyncTest('A rejected promise derived from returning an asynchronously-rejected promise in a fulfillment handler does trigger unhandledRejection', function(done) {
318+
asyncTest('A rejected promise derived from returning an' +
319+
' asynchronously-rejected promise in a fulfillment handler' +
320+
' does trigger unhandledRejection', function(done) {
298321
var e = new Error();
299322
var _promise;
300323
onUnhandledSucceed(done, function(reason, promise) {
@@ -310,7 +333,8 @@ asyncTest('A rejected promise derived from returning an asynchronously-rejected
310333
});
311334
});
312335

313-
asyncTest('A rejected promise derived from throwing in a fulfillment handler does trigger unhandledRejection', function(done) {
336+
asyncTest('A rejected promise derived from throwing in a fulfillment handler' +
337+
' does trigger unhandledRejection', function(done) {
314338
var e = new Error();
315339
var _promise;
316340
onUnhandledSucceed(done, function(reason, promise) {
@@ -322,7 +346,9 @@ asyncTest('A rejected promise derived from throwing in a fulfillment handler doe
322346
});
323347
});
324348

325-
asyncTest('A rejected promise derived from returning a synchronously-rejected promise in a fulfillment handler does trigger unhandledRejection', function(done) {
349+
asyncTest('A rejected promise derived from returning a synchronously-rejected' +
350+
' promise in a fulfillment handler does trigger unhandledRejection',
351+
function(done) {
326352
var e = new Error();
327353
var _promise;
328354
onUnhandledSucceed(done, function(reason, promise) {
@@ -335,13 +361,16 @@ asyncTest('A rejected promise derived from returning a synchronously-rejected pr
335361
});
336362

337363
// Combinations with Promise.all
338-
asyncTest('Catching the Promise.all() of a collection that includes a rejected promise prevents unhandledRejection', function(done) {
364+
asyncTest('Catching the Promise.all() of a collection that includes a' +
365+
'rejected promise prevents unhandledRejection', function(done) {
339366
var e = new Error();
340367
onUnhandledFail(done);
341368
Promise.all([Promise.reject(e)]).then(assert.fail, function() {});
342369
});
343370

344-
asyncTest('Catching the Promise.all() of a collection that includes a nextTick-async rejected promise prevents unhandledRejection', function(done) {
371+
asyncTest('Catching the Promise.all() of a collection that includes a ' +
372+
'nextTick-async rejected promise prevents unhandledRejection',
373+
function(done) {
345374
var e = new Error();
346375
onUnhandledFail(done);
347376
var p = new Promise(function(_, reject) {
@@ -355,7 +384,9 @@ asyncTest('Catching the Promise.all() of a collection that includes a nextTick-a
355384
});
356385
});
357386

358-
asyncTest('Failing to catch the Promise.all() of a collection that includes a rejected promise triggers unhandledRejection for the returned promise, not the passed promise', function(done) {
387+
asyncTest('Failing to catch the Promise.all() of a collection that includes' +
388+
' a rejected promise triggers unhandledRejection for the returned' +
389+
' promise, not the passed promise', function(done) {
359390
var e = new Error();
360391
onUnhandledSucceed(done, function(reason, promise) {
361392
assert.strictEqual(e, reason);
@@ -364,7 +395,8 @@ asyncTest('Failing to catch the Promise.all() of a collection that includes a re
364395
var p = Promise.all([Promise.reject(e)]);
365396
});
366397

367-
asyncTest('Waiting setTimeout(, 10) to catch a promise causes an unhandledRejection + rejectionHandled pair', function(done) {
398+
asyncTest('Waiting setTimeout(, 10) to catch a promise causes an' +
399+
' unhandledRejection + rejectionHandled pair', function(done) {
368400
clean();
369401
var unhandledPromises = [];
370402
var e = new Error();
@@ -389,7 +421,9 @@ asyncTest('Waiting setTimeout(, 10) to catch a promise causes an unhandledReject
389421
}, 10);
390422
});
391423

392-
asyncTest('Waiting for some combination of process.nextTick + promise microtasks to attach a catch handler is still soon enough to prevent unhandledRejection', function(done) {
424+
asyncTest('Waiting for some combination of process.nextTick + promise' +
425+
' microtasks to attach a catch handler is still soon enough to' +
426+
' prevent unhandledRejection', function(done) {
393427
var e = new Error();
394428
onUnhandledFail(done);
395429

@@ -406,7 +440,9 @@ asyncTest('Waiting for some combination of process.nextTick + promise microtasks
406440
});
407441
});
408442

409-
asyncTest('Waiting for some combination of process.nextTick + promise microtasks to attach a catch handler is still soon enough to prevent unhandledRejection: inside setImmediate', function(done) {
443+
asyncTest('Waiting for some combination of process.nextTick + promise' +
444+
' microtasks to attach a catch handler is still soon enough to ' +
445+
'prevent unhandledRejection: inside setImmediate', function(done) {
410446
var e = new Error();
411447
onUnhandledFail(done);
412448

@@ -424,7 +460,9 @@ asyncTest('Waiting for some combination of process.nextTick + promise microtasks
424460
});
425461
});
426462

427-
asyncTest('Waiting for some combination of process.nextTick + promise microtasks to attach a catch handler is still soon enough to prevent unhandledRejection: inside setTimeout', function(done) {
463+
asyncTest('Waiting for some combination of process.nextTick + promise ' +
464+
'microtasks to attach a catch handler is still soon enough to ' +
465+
'prevent unhandledRejection: inside setTimeout', function(done) {
428466
var e = new Error();
429467
onUnhandledFail(done);
430468

@@ -442,7 +480,9 @@ asyncTest('Waiting for some combination of process.nextTick + promise microtasks
442480
}, 0);
443481
});
444482

445-
asyncTest('Waiting for some combination of promise microtasks + process.nextTick to attach a catch handler is still soon enough to prevent unhandledRejection', function(done) {
483+
asyncTest('Waiting for some combination of promise microtasks + ' +
484+
'process.nextTick to attach a catch handler is still soon enough' +
485+
' to prevent unhandledRejection', function(done) {
446486
var e = new Error();
447487
onUnhandledFail(done);
448488

@@ -459,7 +499,10 @@ asyncTest('Waiting for some combination of promise microtasks + process.nextTick
459499
});
460500
});
461501

462-
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) {
502+
asyncTest('Waiting for some combination of promise microtasks +' +
503+
' process.nextTick to attach a catch handler is still soon enough' +
504+
' to prevent unhandledRejection: inside setImmediate',
505+
function(done) {
463506
var e = new Error();
464507
onUnhandledFail(done);
465508

@@ -477,7 +520,9 @@ asyncTest('Waiting for some combination of promise microtasks + process.nextTick
477520
});
478521
});
479522

480-
asyncTest('Waiting for some combination of promise microtasks + process.nextTick to attach a catch handler is still soon enough to prevent unhandledRejection: inside setTimeout', function(done) {
523+
asyncTest('Waiting for some combination of promise microtasks +' +
524+
' process.nextTick to attach a catch handler is still soon enough' +
525+
' to prevent unhandledRejection: inside setTimeout', function(done) {
481526
var e = new Error();
482527
onUnhandledFail(done);
483528

@@ -495,7 +540,9 @@ asyncTest('Waiting for some combination of promise microtasks + process.nextTick
495540
}, 0);
496541
});
497542

498-
asyncTest('setImmediate + promise microtasks is too late to attach a catch handler; unhandledRejection will be triggered in that case. (setImmediate before promise creation/rejection)', function(done) {
543+
asyncTest('setImmediate + promise microtasks is too late to attach a catch' +
544+
' handler; unhandledRejection will be triggered in that case.' +
545+
' (setImmediate before promise creation/rejection)', function(done) {
499546
var e = new Error();
500547
onUnhandledSucceed(done, function(reason, promise) {
501548
assert.strictEqual(e, reason);
@@ -509,7 +556,9 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch handl
509556
});
510557
});
511558

512-
asyncTest('setImmediate + promise microtasks is too late to attach a catch handler; unhandledRejection will be triggered in that case (setImmediate before promise creation/rejection)', function(done) {
559+
asyncTest('setImmediate + promise microtasks is too late to attach a catch' +
560+
' handler; unhandledRejection will be triggered in that case' +
561+
' (setImmediate before promise creation/rejection)', function(done) {
513562
onUnhandledSucceed(done, function(reason, promise) {
514563
assert.strictEqual(undefined, reason);
515564
assert.strictEqual(p, promise);
@@ -528,7 +577,9 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch handl
528577
var p = Promise.reject();
529578
});
530579

531-
asyncTest('setImmediate + promise microtasks is too late to attach a catch handler; unhandledRejection will be triggered in that case (setImmediate after promise creation/rejection)', function(done) {
580+
asyncTest('setImmediate + promise microtasks is too late to attach a catch' +
581+
' handler; unhandledRejection will be triggered in that case' +
582+
' (setImmediate after promise creation/rejection)', function(done) {
532583
onUnhandledSucceed(done, function(reason, promise) {
533584
assert.strictEqual(undefined, reason);
534585
assert.strictEqual(p, promise);
@@ -547,7 +598,9 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch handl
547598
});
548599
});
549600

550-
asyncTest('Promise unhandledRejection handler does not interfere with domain error handlers being given exceptions thrown from nextTick.', function(done) {
601+
asyncTest('Promise unhandledRejection handler does not interfere with domain' +
602+
' error handlers being given exceptions thrown from nextTick.',
603+
function(done) {
551604
var d = domain.create();
552605
var domainReceivedError;
553606
d.on('error', function(e) {
@@ -568,7 +621,8 @@ asyncTest('Promise unhandledRejection handler does not interfere with domain err
568621
});
569622
});
570623

571-
asyncTest('nextTick is immediately scheduled when called inside an event handler', function(done) {
624+
asyncTest('nextTick is immediately scheduled when called inside an event' +
625+
' handler', function(done) {
572626
clean();
573627
var e = new Error('error');
574628
process.on('unhandledRejection', function(reason, promise) {
@@ -585,7 +639,9 @@ asyncTest('nextTick is immediately scheduled when called inside an event handler
585639
Promise.reject(e);
586640
});
587641

588-
asyncTest('Throwing an error inside a rejectionHandled handler goes to unhandledException, and does not cause .catch() to throw an exception', function(done) {
642+
asyncTest('Throwing an error inside a rejectionHandled handler goes to' +
643+
' unhandledException, and does not cause .catch() to throw an' +
644+
'exception', function(done) {
589645
clean();
590646
var e = new Error();
591647
var e2 = new Error();

0 commit comments

Comments
 (0)