From 902df84fce790178da78c5830498911a487d50cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 12 Nov 2012 11:19:20 -0500 Subject: [PATCH] Tests: Allow async domEqual() tests. --- tests/unit/testsuite.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index f3c0982fb..42fdf4f9e 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -271,11 +271,22 @@ window.domEqual = function( selector, modifier, message ) { } return result; } + + function done() { + actual = extract( $( selector ) ); + QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); + } + + // Get current state prior to modifier expected = extract( $( selector ) ); - modifier( $( selector ) ); - actual = extract( $( selector ) ); - QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); + // Run modifier (async or sync), then compare state via done() + if ( modifier.length ) { + modifier( done ); + } else { + modifier(); + done(); + } }; }( jQuery )); -- 2.39.5