Skip to content

Commit

Permalink
Tests: Address feedback, use more idiomatic promise chaining.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue authored and trentmwillis committed Dec 20, 2017
1 parent 2f52665 commit 81e0f69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
19 changes: 8 additions & 11 deletions test/cli/fixtures/unhandled-rejection.js
Expand Up @@ -6,19 +6,16 @@ QUnit.module( "Unhandled Rejections", function() {

const done = assert.async();

new Promise( function( resolve ) {
setTimeout( resolve );
} )
.then( function() {
Promise.resolve().then( function() {

// throwing a non-Error here because stack trace representation
// across Node versions is not stable (they continue to get better)
throw {
message: "Error thrown in non-returned promise!",
stack: `Error: Error thrown in non-returned promise!
// throwing a non-Error here because stack trace representation
// across Node versions is not stable (they continue to get better)
throw {
message: "Error thrown in non-returned promise!",
stack: `Error: Error thrown in non-returned promise!
at /some/path/wherever/unhandled-rejection.js:13:11`
};
} );
};
} );

// prevent test from exiting before unhandled rejection fires
setTimeout( done, 10 );
Expand Down
9 changes: 3 additions & 6 deletions test/reporter-html/unhandled-rejection.js
Expand Up @@ -17,12 +17,9 @@ if ( HAS_UNHANDLED_REJECTION_HANDLER ) {
QUnit.test( "test passes just fine, but has a rejected promise", function( assert ) {
const done = assert.async();

new Promise( function( resolve ) {
setTimeout( resolve );
} )
.then( function() {
throw new Error( "Error thrown in non-returned promise!" );
} );
Promise.resolve().then( function() {
throw new Error( "Error thrown in non-returned promise!" );
} );

// prevent test from exiting before unhandled rejection fires
setTimeout( done, 10 );
Expand Down

0 comments on commit 81e0f69

Please sign in to comment.