Skip to content
Permalink
Browse files

Widget: Added tests for re-initialization.

  • Loading branch information...
scottgonzalez committed Aug 23, 2010
1 parent 2838c11 commit df786f80ebffc0882af7f33a77e0900f46c6ab15
Showing with 29 additions and 0 deletions.
  1. +29 −0 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() {}

0 comments on commit df786f8

Please sign in to comment.
You can’t perform that action at this time.