summaryrefslogtreecommitdiff
path: root/tests/qunit/suites/resources/jquery/jquery.delayedBind.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/qunit/suites/resources/jquery/jquery.delayedBind.test.js')
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.delayedBind.test.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/qunit/suites/resources/jquery/jquery.delayedBind.test.js b/tests/qunit/suites/resources/jquery/jquery.delayedBind.test.js
new file mode 100644
index 00000000..234b19cb
--- /dev/null
+++ b/tests/qunit/suites/resources/jquery/jquery.delayedBind.test.js
@@ -0,0 +1,37 @@
+( function ( $ ) {
+ QUnit.asyncTest( 'jquery.delayedBind with data option', 2, function ( assert ) {
+ var $fixture = $( '<div>' ).appendTo( '#qunit-fixture' ),
+ data = {
+ magic: 'beeswax'
+ },
+ delay = 50;
+
+ $fixture.delayedBind( delay, 'testevent', data, function ( e ) {
+ assert.ok( true, 'testevent fired' );
+ assert.ok( e.data === data, 'data is passed through delayedBind' );
+ QUnit.start();
+ } );
+
+ // We'll trigger it thrice, but it should only happen once.
+ $fixture.trigger( 'testevent', {} );
+ $fixture.trigger( 'testevent', {} );
+ $fixture.trigger( 'testevent', {} );
+ $fixture.trigger( 'testevent', {} );
+ } );
+
+ QUnit.asyncTest( 'jquery.delayedBind without data option', 1, function ( assert ) {
+ var $fixture = $( '<div>' ).appendTo( '#qunit-fixture' ),
+ delay = 50;
+
+ $fixture.delayedBind( delay, 'testevent', function () {
+ assert.ok( true, 'testevent fired' );
+ QUnit.start();
+ } );
+
+ // We'll trigger it thrice, but it should only happen once.
+ $fixture.trigger( 'testevent', {} );
+ $fixture.trigger( 'testevent', {} );
+ $fixture.trigger( 'testevent', {} );
+ $fixture.trigger( 'testevent', {} );
+ } );
+}( jQuery ) );