From 51bd6f8927adf4f467db8a7b33dd5418769d77b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Tue, 21 Feb 2012 18:08:14 +0100 Subject: [PATCH] Selectmenu: Unit tests whitespace and linting/cleanup --- tests/unit/selectmenu/selectmenu_core.js | 20 ++++---- tests/unit/selectmenu/selectmenu_events.js | 2 +- tests/unit/selectmenu/selectmenu_methods.js | 56 ++++++++++----------- tests/unit/selectmenu/selectmenu_options.js | 14 +++--- 4 files changed, 46 insertions(+), 46 deletions(-) diff --git a/tests/unit/selectmenu/selectmenu_core.js b/tests/unit/selectmenu/selectmenu_core.js index d3b2bfa81..c6dff8a74 100644 --- a/tests/unit/selectmenu/selectmenu_core.js +++ b/tests/unit/selectmenu/selectmenu_core.js @@ -11,17 +11,17 @@ test("accessibility", function () { selected = element.find("option:selected"), ul = menu.children("ul"), links = ul.find("li.ui-menu-item a"); - + expect(13 + links.length * 2); - + equals( link.attr("role"), "combobox", "button link role" ); equals( link.attr("aria-haspopup"), "true", "button link aria-haspopup" ); equals( link.attr("aria-expanded"), "false", "button link aria-expanded" ); equals( link.attr("aria-autocomplete"), "list", "button link aria-autocomplete" ); equals( link.attr("aria-activedescendant"), links.eq(element[0].selectedIndex).attr("id"), "button link aria-activedescendant" ); equals( link.attr("aria-owns"), ul.attr("id"), "button link aria-owns" ); - equals( link.attr("tabindex"), 0, "button link tabindex" ); - + equals( link.attr("tabindex"), 0, "button link tabindex" ); + equals( ul.attr("role"), "listbox", "menu role" ); equals( ul.attr("aria-labelledby"), link.attr("id"), "menu aria-labelledby" ); equals( ul.attr("aria-hidden"), "true", "menu aria-hidden" ); @@ -47,7 +47,7 @@ $.each([ ], function( i, settings ) { test("state synchronization - " + settings.type, function () { expect(10); - + var element = $(settings.selector).selectmenu(), widget = element.selectmenu("widget"), button = widget.filter(".ui-selectmenu-button"), @@ -56,20 +56,20 @@ $.each([ ul = menu.children("ul"), links = ul.find("li.ui-menu-item a"), selected = element.find("option:selected"); - - link.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + + link.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); equals( ul.attr("aria-activedescendant"), links.eq(element[0].selectedIndex).attr("id"), "after keydown menu aria-activedescendant" ); equals( link.attr("aria-activedescendant"), links.eq(element[0].selectedIndex).attr("id"), "after keydown button link aria-activedescendant" ); equals( links.eq(element[0].selectedIndex).attr("aria-selected"), "true", "after keydown selected menu link aria-selected" ); - equals( element.find("option:selected").val(), selected.next("option").val() , "after keydown original select state" ); + equals( element.find("option:selected").val(), selected.next("option").val() , "after keydown original select state" ); equals( button.text(), selected.next("option").text(), "after keydown button text" ); - + link.simulate( "click" ); menu.find("a").last().simulate( "mouseover" ).trigger( "click" ); equals( ul.attr("aria-activedescendant"), links.eq(element[0].selectedIndex).attr("id"), "after click menu aria-activedescendant" ); equals( link.attr("aria-activedescendant"), links.eq(element[0].selectedIndex).attr("id"), "after click button link aria-activedescendant" ); equals( links.eq(element[0].selectedIndex).attr("aria-selected"), "true", "after click selected menu link aria-selected" ); - equals( element.find("option:selected").val(), element.find("option").last().val(), "after click original select state" ); + equals( element.find("option:selected").val(), element.find("option").last().val(), "after click original select state" ); equals( button.text(), element.find("option").last().text(), "after click button text" ); }); }); diff --git a/tests/unit/selectmenu/selectmenu_events.js b/tests/unit/selectmenu/selectmenu_events.js index 92dc6f01a..b5adbc0f5 100644 --- a/tests/unit/selectmenu/selectmenu_events.js +++ b/tests/unit/selectmenu/selectmenu_events.js @@ -15,7 +15,7 @@ test("change", function () { equals(event.type, "selectmenuchange", "event type set to selectmenuchange"); ok(ui, "ui object is passed as second argument to event handler"); equals(ui.item.element[0].nodeName, "OPTION", "ui.item.element[0] points to original option element"); - equals(ui.item.value, value, "ui.item.value property updated correctly"); + equals(ui.item.value, value, "ui.item.value property updated correctly"); } }); diff --git a/tests/unit/selectmenu/selectmenu_methods.js b/tests/unit/selectmenu/selectmenu_methods.js index 47e76053d..942ab9e7b 100644 --- a/tests/unit/selectmenu/selectmenu_methods.js +++ b/tests/unit/selectmenu/selectmenu_methods.js @@ -12,16 +12,16 @@ test( "destroy", function() { test( "open / close", function() { expect( 4 ); - + var element = $('#speed').selectmenu(), widget = element.selectmenu("widget"), button = widget.filter(".ui-selectmenu-button"), menu = widget.filter(".ui-selectmenu-menu"); - + element.selectmenu("open"); ok( menu.is( ":visible" ), "menu visible" ); equals( menu.find("ul").attr("aria-hidden"), "false", "menu aria-disabled" ); - + element.selectmenu("close"); ok( menu.is( ":hidden" ), "menu hidden" ); equals( menu.find("ul").attr("aria-hidden"), "true", "menu aria-disabled" ); @@ -30,14 +30,14 @@ test( "open / close", function() { test("enable / disable", function () { expect(14); - + var element = $('#speed').selectmenu(), widget = element.selectmenu("widget"), button = widget.filter(".ui-selectmenu-button"), menu = widget.filter(".ui-selectmenu-menu"), link = button.find("a"); - - element.selectmenu("disable") + + element.selectmenu("disable"); ok( element.selectmenu("option", "disabled"), "disable: widget option" ); equals( element.attr("disabled"), "disabled", "disable: native select disabled" ); equals( button.attr("aria-disabled"), "true", "disable: button wrapper ARIA" ); @@ -45,8 +45,8 @@ test("enable / disable", function () { equals( link.attr("tabindex"), -1, "disable: button tabindex" ); equals( menu.attr("aria-disabled"), "true", "disable: menu wrapper ARIA" ); equals( menu.children("ul").attr("aria-disabled"), "true", "disable: menu ARIA" ); - - element.selectmenu("enable") + + element.selectmenu("enable"); ok( !element.selectmenu("option", "disabled"), "enable: widget option" ); equals( element.attr("disabled"), undefined, "enable: native select disabled" ); equals( button.attr("aria-disabled"), "false", "enable: button wrapper ARIA" ); @@ -59,12 +59,12 @@ test("enable / disable", function () { test("refresh - structure", function () { expect(3); - + var element = $('#speed').selectmenu(), widget = element.selectmenu("widget"), button = widget.filter(".ui-selectmenu-button"), menu = widget.filter(".ui-selectmenu-menu"); - + element.find("option").eq(2).remove(); element.find("option").eq(3).remove(); element.append(''); @@ -72,24 +72,24 @@ test("refresh - structure", function () { .attr("value", "changed_value") .text("Changed value"); element.selectmenu("refresh"); - - equals( element.find("option").length, menu.find("li").not(".ui-selectmenu-optgroup").length, "menu item length" ); - equals( element.find("option").last().text(), menu.find("li").not(".ui-selectmenu-optgroup").last().text(), "added item" ); + + equals( element.find("option").length, menu.find("li").not(".ui-selectmenu-optgroup").length, "menu item length" ); + equals( element.find("option").last().text(), menu.find("li").not(".ui-selectmenu-optgroup").last().text(), "added item" ); equals( element.find("option").first().text(), menu.find("li").not(".ui-selectmenu-optgroup").first().text(), "chnaged item" ); }); test("refresh - disabled select", function () { expect(6); - + var element = $('#speed').selectmenu(), widget = element.selectmenu("widget"), button = widget.filter(".ui-selectmenu-button"), menu = widget.filter(".ui-selectmenu-menu"); - + element.attr("disabled", "disabled"); element.selectmenu("refresh"); - + ok( element.selectmenu("option", "disabled"), "widget option" ); equals( button.attr("aria-disabled"), "true", "button wrapper ARIA" ); equals( button.children("a").attr("aria-disabled"), "true", "button ARIA" ); @@ -101,39 +101,39 @@ test("refresh - disabled select", function () { test("refresh - disabled option", function () { expect(2); - + var element = $('#speed').selectmenu(), widget = element.selectmenu("widget"), button = widget.filter(".ui-selectmenu-button"), menu = widget.filter(".ui-selectmenu-menu"); - + element.attr("disabled", "disabled"); element.find("option").eq(2).attr("disabled", "disabled"); element.selectmenu("refresh"); - - var disabledItem = menu.find("li").not(".ui-selectmenu-optgroup").eq(2); + + var disabledItem = menu.find("li").not(".ui-selectmenu-optgroup").eq(2); ok( disabledItem.hasClass("ui-state-disabled"), "class" ); ok( disabledItem.children("a").length <= 0, "has no link" ); }); - - + + test("refresh - disabled optgroup", function () { - + var element = $('#files').selectmenu(), widget = element.selectmenu("widget"), button = widget.filter(".ui-selectmenu-button"), - menu = widget.filter(".ui-selectmenu-menu"); + menu = widget.filter(".ui-selectmenu-menu"), originalDisabledOptgroup = element.find("optgroup").first(), originalDisabledOptions = originalDisabledOptgroup.find("option"); - + expect(2 + originalDisabledOptions.length * 2); - + originalDisabledOptgroup.attr("disabled", "disabled"); element.selectmenu("refresh"); - + var item = menu.find("li.ui-selectmenu-optgroup").first(); ok( item.hasClass("ui-state-disabled"), "class" ); - + equals( menu.find("li").not(".ui-selectmenu-optgroup").filter(".ui-state-disabled").length, originalDisabledOptions.length, "disabled options" ); for ( var i = 0; i < originalDisabledOptions.length; i++ ) { item = item.next("li"); diff --git a/tests/unit/selectmenu/selectmenu_options.js b/tests/unit/selectmenu/selectmenu_options.js index 993086b27..d5a787455 100644 --- a/tests/unit/selectmenu/selectmenu_options.js +++ b/tests/unit/selectmenu/selectmenu_options.js @@ -16,22 +16,22 @@ test("appendTo another element", function () { test("dropdown: CSS styles", function () { expect(4); - + var widget = this.element.selectmenu("widget"), button = widget.filter(".ui-selectmenu-button"), link = button.find("a"), menu = widget.filter(".ui-selectmenu-menu"), ul = widget.find("ul"); - this.element.selectmenu("open"); - ok( link.hasClass("ui-corner-top") && !link.hasClass("ui-corner-all"), "button styles dropdown"); - ok( ul.hasClass("ui-corner-bottom") && !ul.hasClass("ui-corner-all"), "menu styles dropdown"); - + this.element.selectmenu("open"); + ok( link.hasClass("ui-corner-top") && !link.hasClass("ui-corner-all"), "button styles dropdown"); + ok( ul.hasClass("ui-corner-bottom") && !ul.hasClass("ui-corner-all"), "menu styles dropdown"); + this.element.selectmenu("close"); this.element.selectmenu("option", "dropdown", false); this.element.selectmenu("open"); - ok( !link.hasClass("ui-corner-top") && link.hasClass("ui-corner-all"), "button styles pop-up"); - ok( !ul.hasClass("ui-corner-bottom") && ul.hasClass("ui-corner-all"), "menu styles pop-up"); + ok( !link.hasClass("ui-corner-top") && link.hasClass("ui-corner-all"), "button styles pop-up"); + ok( !ul.hasClass("ui-corner-bottom") && ul.hasClass("ui-corner-all"), "menu styles pop-up"); }); })(jQuery);