Skip to content

Commit df786f8

Browse files
committed
Widget: Added tests for re-initialization.
1 parent 2838c11 commit df786f8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/unit/widget/widget_core.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,35 @@ test('merge multiple option arguments', function() {
146146
});
147147
});
148148

149+
test("re-init", function() {
150+
var div = $( "<div></div>" ),
151+
actions = [];
152+
153+
$.widget( "ui.testWidget", {
154+
_create: function() {
155+
actions.push( "create" );
156+
},
157+
_init: function() {
158+
actions.push( "init" );
159+
},
160+
_setOption: function( key, value ) {
161+
actions.push( "option" + key );
162+
}
163+
});
164+
165+
actions = [];
166+
div.testWidget({ foo: "bar" });
167+
same( actions, [ "create", "init" ], "correct methods called on init" );
168+
169+
actions = [];
170+
div.testWidget();
171+
same( actions, [ "init" ], "correct methods call on re-init" );
172+
173+
actions = [];
174+
div.testWidget({ foo: "bar" });
175+
same( actions, [ "optionfoo", "init" ], "correct methods called on re-init with options" );
176+
});
177+
149178
test(".widget() - base", function() {
150179
$.widget("ui.testWidget", {
151180
_create: function() {}

0 commit comments

Comments
 (0)