From 2a6ca3fb394f2caee6ad92c4dfc76ac66553cd46 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Mon, 12 Sep 2011 23:37:14 +0200 Subject: Widget: Add a _delay method. Will be used in various places to replace setTimeout with custom binding (mostly getting rid of var self/that) --- tests/unit/widget/widget_core.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/unit') diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 0c4142539..0b272a0d5 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -1040,4 +1040,28 @@ test( "redefine", function() { equal( $.ui.testWidget.foo, "bar", "static properties remain" ); }); +asyncTest( "_delay", function() { + expect( 4 ); + var order = 0, + that; + $.widget( "ui.testWidget", { + defaultElement: null, + _create: function() { + that = this; + this._delay(function() { + strictEqual( this, that ); + equal( order, 1 ); + start(); + }, 500); + this._delay("callback"); + }, + callback: function() { + strictEqual( this, that ); + equal( order, 0 ); + order += 1; + } + }); + $( "#widget" ).testWidget(); +}); + }( jQuery ) ); -- cgit v1.2.3