diff options
author | Scott González <scott.gonzalez@gmail.com> | 2010-09-03 09:49:29 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2010-09-03 09:49:29 -0400 |
commit | 0a0a39f896f83412dc91bedd6819c3a3a0932302 (patch) | |
tree | b6ae6d6a9639b16f5f709f9ca95a0ccba40f086f /tests/unit/widget/widget_core.js | |
parent | e5f3bfce4d2f761eea536d61f1282beca19fc774 (diff) | |
download | jquery-ui-0a0a39f896f83412dc91bedd6819c3a3a0932302.tar.gz jquery-ui-0a0a39f896f83412dc91bedd6819c3a3a0932302.zip |
Widget: Hook into jQuery.cleanData to auto-destroy widgets. Fixes #6008 - Widget: auto-destroy is broken in jQuery 1.4.
Diffstat (limited to 'tests/unit/widget/widget_core.js')
-rw-r--r-- | tests/unit/widget/widget_core.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 2d5502838..604222106 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -409,4 +409,71 @@ test( "._trigger() - provide event and ui", function() { .testWidget( "testEvent" ); }); +test( "auto-destroy - .remove()", function() { + expect( 1 ); + $.widget( "ui.testWidget", { + _create: function() {}, + destroy: function() { + ok( true, "destroyed from .remove()" ); + } + }); + $( "#widget" ).testWidget().remove(); +}); + +test( "auto-destroy - .remove() on parent", function() { + expect( 1 ); + $.widget( "ui.testWidget", { + _create: function() {}, + destroy: function() { + ok( true, "destroyed from .remove() on parent" ); + } + }); + $( "#widget" ).testWidget().parent().remove(); +}); + +test( "auto-destroy - .remove() on child", function() { + $.widget( "ui.testWidget", { + _create: function() {}, + destroy: function() { + ok( false, "destroyed from .remove() on child" ); + } + }); + $( "#widget" ).testWidget().children().remove(); + // http://github.com/jquery/qunit/pull/34 + $.ui.testWidget.prototype.destroy = $.noop; +}); + +test( "auto-destroy - .empty()", function() { + $.widget( "ui.testWidget", { + _create: function() {}, + destroy: function() { + ok( false, "destroyed from .empty()" ); + } + }); + $( "#widget" ).testWidget().empty(); + // http://github.com/jquery/qunit/pull/34 + $.ui.testWidget.prototype.destroy = $.noop; +}); + +test( "auto-destroy - .empty() on parent", function() { + expect( 1 ); + $.widget( "ui.testWidget", { + _create: function() {}, + destroy: function() { + ok( true, "destroyed from .empty() on parent" ); + } + }); + $( "#widget" ).testWidget().parent().empty(); +}); + +test( "auto-destroy - .detach()", function() { + $.widget( "ui.testWidget", { + _create: function() {}, + destroy: function() { + ok( false, "destroyed from .detach()" ); + } + }); + $( "#widget" ).testWidget().detach(); +}); + })( jQuery ); |