diff options
author | Scott González <scott.gonzalez@gmail.com> | 2010-08-23 15:35:28 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2010-08-23 15:35:28 -0400 |
commit | df786f80ebffc0882af7f33a77e0900f46c6ab15 (patch) | |
tree | 1145e0927f9a836db8fa5f1f2799f279bf3b00ba /tests/unit | |
parent | 2838c11ea8fa1bd8dfffe27a6e28dee6d3e0d423 (diff) | |
download | jquery-ui-df786f80ebffc0882af7f33a77e0900f46c6ab15.tar.gz jquery-ui-df786f80ebffc0882af7f33a77e0900f46c6ab15.zip |
Widget: Added tests for re-initialization.
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/widget/widget_core.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 3c870f1fe..39cdf3e9c 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -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() {} |