]> source.dussan.org Git - jquery-ui.git/commitdiff
Widget: Added tests for re-initialization.
authorScott González <scott.gonzalez@gmail.com>
Mon, 23 Aug 2010 19:35:28 +0000 (15:35 -0400)
committerScott González <scott.gonzalez@gmail.com>
Mon, 23 Aug 2010 19:35:28 +0000 (15:35 -0400)
tests/unit/widget/widget_core.js

index 3c870f1fe18f217842d35b21e017d247c15e7a03..39cdf3e9c1637ef7510f5292e18f13ff1af77972 100644 (file)
@@ -146,6 +146,35 @@ test('merge multiple option arguments', function() {
        });
 });
 
+test("re-init", function() {
+       var div = $( "<div></div>" ),
+               actions = [];
+
+       $.widget( "ui.testWidget", {
+               _create: function() {
+                       actions.push( "create" );
+               },
+               _init: function() {
+                       actions.push( "init" );
+               },
+               _setOption: function( key, value ) {
+                       actions.push( "option" + key );
+               }
+       });
+
+       actions = [];
+       div.testWidget({ foo: "bar" });
+       same( actions, [ "create", "init" ], "correct methods called on init" );
+
+       actions = [];
+       div.testWidget();
+       same( actions, [ "init" ], "correct methods call on re-init" );
+
+       actions = [];
+       div.testWidget({ foo: "bar" });
+       same( actions, [ "optionfoo", "init" ], "correct methods called on re-init with options" );
+});
+
 test(".widget() - base", function() {
        $.widget("ui.testWidget", {
                _create: function() {}