diff --git a/test/main/each.js b/test/main/each.js index c8a3f8daf..e829bce7a 100644 --- a/test/main/each.js +++ b/test/main/each.js @@ -2,14 +2,6 @@ QUnit.module( "test.each", function() { QUnit.test.each( "test.each", [ [ 1, 2, 3 ], [ 1, 1, 2 ] ], function( assert, data ) { assert.strictEqual( data[ 0 ] + data[ 1 ], data[ 2 ] ); } ); - QUnit.test.each( "test.each returning a Promise", [ [ 1, 2, 3 ], [ 1, 1, 2 ] ], function( assert, data ) { - function sum( a, b ) { - return new Promise( function( resolve ) { - resolve( a + b ); - } ); - } - return sum( data[ 0 ], data[ 1 ] ).then( function( result ) { assert.strictEqual( result, data[ 2 ] ); } ); - } ); QUnit.test.each( "test.each 1D", [ 1, [], "some" ], function( assert, value ) { assert.true( Boolean( value ) ); } ); @@ -22,6 +14,8 @@ QUnit.module( "test.each", function() { } ); } ); + // Promise support for test.each() is tested in test/main/promise.js. + QUnit.module( "arguments", function( hooks ) { var todoArgs; hooks.after( function( assert ) { diff --git a/test/main/promise.js b/test/main/promise.js index fc2527327..33c2c4ce3 100644 --- a/test/main/promise.js +++ b/test/main/promise.js @@ -216,4 +216,35 @@ QUnit.module( "Support for Promise", function() { return createMockPromise( assert, true, "this is an error" ); } ); + + QUnit.module( "test.each()", { + afterEach: function( assert ) { + + // Restore + if ( this.pushFailure ) { + assert.test.pushFailure = this.pushFailure; + } + } + } ); + + QUnit.test.each( "fulfilled Promise", [ 1 ], function( assert, _data ) { + assert.expect( 1 ); + + // Adds 1 assertion + return createMockPromise( assert ); + } ); + + QUnit.test.each( "rejected Promise with Error", [ 1 ], function( assert, _data ) { + assert.expect( 2 ); + + this.pushFailure = assert.test.pushFailure; + assert.test.pushFailure = function( message ) { + assert.strictEqual( + message, + "Promise rejected during \"rejected Promise with Error [0]\": this is an error" + ); + }; + + return createMockPromise( assert, true, new Error( "this is an error" ) ); + } ); } );