Skip to content

Commit 7840ea9

Browse files
author
Jan Malac
committed
added refresh tests for selectmenu without options
1 parent be93bd7 commit 7840ea9

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/unit/selectmenu/selectmenu_methods.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,39 @@ test( "refresh - disabled optgroup", function() {
154154
}
155155
});
156156

157+
test( "refresh - empty select", function() {
158+
expect( 1 );
159+
160+
var element = $( "#emptySelect" ).selectmenu();
161+
try{
162+
element.selectmenu( "refresh" );
163+
ok( true, "refresh empty select without error" );
164+
}catch(err) {
165+
ok( false, err.message );
166+
}
167+
});
168+
169+
test( "refresh - structure remove all options", function() {
170+
expect( 4 );
171+
172+
var element = $( "#speed" ).selectmenu(),
173+
menu = element.selectmenu( "menuWidget" ),
174+
options = element.find( "option" ),
175+
menuItems = menu.find( "li" ).not( ".ui-selectmenu-optgroup" );
176+
// refresh select with some options
177+
element.selectmenu( "refresh" );
178+
ok( true, "first refresh ok" );
179+
// remove all options and refresh
180+
element.children().remove();
181+
element.selectmenu( "refresh" );
182+
ok( true, "refresh empty select ok" );
183+
//check length for option and menuItems is 0
184+
options = element.find( "option" );
185+
menuItems = menu.find( "li" ).not( ".ui-selectmenu-optgroup" );
186+
equal( options.length, 0, "options length" );
187+
equal( menuItems.length, 0, "menu item length" );
188+
});
189+
157190
test( "widget and menuWidget", function() {
158191
expect( 4 );
159192

0 commit comments

Comments
 (0)