This repository has been archived by the owner on Jul 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Entries: Added assert.async. Deprecated start, stop, and asyncTest
- Loading branch information
1 parent
cae9f27
commit 363b50d
Showing
4 changed files
with
76 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0"?> | ||
<?xml-stylesheet type="text/xsl" href="../entries2html.xsl" ?> | ||
<entry type="method" name="async"> | ||
<title>async()</title> | ||
<desc> | ||
Instruct QUnit to wait for an asynchronous operation. | ||
</desc> | ||
<longdesc> | ||
<p>When your test has any asynchronous exit points, call <code>assert.async()</code> to get a unique resolution callback for each async operation. The callback returned from <code>assert.async()</code> will throw an Error if is invoked more than once.</p> | ||
<p>This replaces functionality previously provided by <a href="/QUnit.stop/"><code>QUnit.stop()</code></a> and <a href="/QUnit.start/"><code>QUnit.start()</code></a>.</p> | ||
</longdesc> | ||
<example height="250"> | ||
<desc>Tell QUnit to wait for the <code>done()</code> call inside the timeout.</desc> | ||
<code><![CDATA[ | ||
QUnit.test( "assert.async() test", function( assert ) { | ||
var done = assert.async(); | ||
var input = $( "#test-input" ).focus(); | ||
setTimeout(function() { | ||
assert.equal( document.activeElement, input[0], "Input was focused" ); | ||
done(); | ||
}); | ||
}); | ||
]]></code> | ||
</example> | ||
<example height="250"> | ||
<desc>Call <code>assert.async()</code> for each operation. Each <code>done</code> callback can be called at most once.</desc> | ||
<code><![CDATA[ | ||
QUnit.test( "two async calls", function( assert ) { | ||
assert.expect( 2 ); | ||
var done1 = assert.async(); | ||
var done2 = assert.async(); | ||
setTimeout(function() { | ||
assert.ok( true, "test resumed from async operation 1" ); | ||
done1(); | ||
}, 500 ); | ||
setTimeout(function() { | ||
assert.ok( true, "test resumed from async operation 2" ); | ||
done2(); | ||
}, 150); | ||
}); | ||
]]></code> | ||
</example> | ||
|
||
<category slug="assert"/> | ||
<category slug="async-control"/> | ||
</entry> |