From 1ab0eef8ca3f2042ba829cd20849d015baccfd14 Mon Sep 17 00:00:00 2001 From: Leonardo Balter Date: Wed, 3 Sep 2014 15:12:45 -0300 Subject: [PATCH] Test: Synchronize accepts an array of functions Ref #647 --- src/core.js | 6 ++++++ src/test.js | 27 +++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/core.js b/src/core.js index 6d9ede8b8..3a9bf4fb5 100644 --- a/src/core.js +++ b/src/core.js @@ -580,6 +580,12 @@ function sourceFromStacktrace( offset ) { } function synchronize( callback, last ) { + if ( QUnit.objectType( callback ) === "array" ) { + while ( callback.length ) { + synchronize( callback.shift() ); + } + return; + } config.queue.push( callback ); if ( config.autorun && !config.blocking ) { diff --git a/src/test.js b/src/test.js index 112c61fed..e9828b37c 100644 --- a/src/test.js +++ b/src/test.js @@ -160,19 +160,22 @@ Test.prototype = { test = this; function run() { + // each of these can by async - synchronize(function() { - test.before(); - }); - synchronize(function() { - test.run(); - }); - synchronize(function() { - test.after(); - }); - synchronize(function() { - test.finish(); - }); + synchronize([ + function() { + test.before(); + }, + function() { + test.run(); + }, + function() { + test.after(); + }, + function() { + test.finish(); + } + ]); } // `bad` initialized at top of scope