aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/selectmenu
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2013-12-05 22:12:05 +0100
committerFelix Nagel <info@felixnagel.com>2013-12-07 19:10:50 +0100
commit1656cd2f340ac94b3b0c337f81eb3b31a4bb4d71 (patch)
tree16b69e56bba28e093542404a980016882666e7d3 /tests/unit/selectmenu
parent06bcd8eb62a9c5662efb7fc1b77f2e82c8061b60 (diff)
downloadjquery-ui-1656cd2f340ac94b3b0c337f81eb3b31a4bb4d71.tar.gz
jquery-ui-1656cd2f340ac94b3b0c337f81eb3b31a4bb4d71.zip
Selectmenu Tests: add unit and visual tests for width option
Diffstat (limited to 'tests/unit/selectmenu')
-rw-r--r--tests/unit/selectmenu/selectmenu_options.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/unit/selectmenu/selectmenu_options.js b/tests/unit/selectmenu/selectmenu_options.js
index 82ea6a8b4..1ab098a75 100644
--- a/tests/unit/selectmenu/selectmenu_options.js
+++ b/tests/unit/selectmenu/selectmenu_options.js
@@ -57,4 +57,43 @@ test( "CSS styles", function () {
ok( menu.hasClass( "ui-corner-bottom" ) && !menu.hasClass( "ui-corner-all" ), "menu styles dropdown" );
});
+
+test( "Width", function () {
+ expect( 8 );
+
+ var element = $( "#speed" ),
+ button, menu;
+
+ element.selectmenu();
+ button = element.selectmenu( "widget" );
+ menu = element.selectmenu( "menuWidget" );
+
+ equal( button.outerWidth(), element.outerWidth(), "button width auto" );
+ element.selectmenu( "open" );
+ equal( menu.outerWidth(), element.outerWidth(), "menu width auto" );
+
+ element.outerWidth( 100 );
+ element.selectmenu( "refresh" );
+
+ equal( button.outerWidth(), 100, "button width set by CSS" );
+ element.selectmenu( "open" );
+ equal( menu.outerWidth(), 100, "menu width set by CSS" );
+
+ element.width( "" );
+ element.selectmenu( "option", "width", 100 );
+ element.selectmenu( "refresh" );
+
+ equal( button.outerWidth(), 100, "button width set by JS option" );
+ element.selectmenu( "open" );
+ equal( menu.outerWidth(), 100, "menu width set by JS option" );
+
+ element.append( $( "<option>", { text: "Option with a little longer text" } ) );
+ element.selectmenu( "option", "width", "" );
+ element.selectmenu( "refresh" );
+
+ equal( button.outerWidth(), element.outerWidth(), "button width with long option" );
+ element.selectmenu( "open" );
+ ok( menu.outerWidth() >= element.outerWidth(), "menu width with long option" );
+});
+
})( jQuery );