Skip to content

Commit

Permalink
Test: Synchronize accepts an array of functions
Browse files Browse the repository at this point in the history
Ref #647
  • Loading branch information
leobalter committed Sep 4, 2014
1 parent 8c9ea95 commit 1ab0eef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
6 changes: 6 additions & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
27 changes: 15 additions & 12 deletions src/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1ab0eef

Please sign in to comment.