From 37a80477c0fbd272b91d9b3cf6bcdc7903655e79 Mon Sep 17 00:00:00 2001 From: Felix Nagel Date: Thu, 24 May 2012 18:54:47 +0200 Subject: [PATCH] Selectmenu: small fixes for lint tests --- tests/unit/selectmenu/selectmenu_core.js | 12 +++++++----- tests/unit/selectmenu/selectmenu_events.js | 8 +++++--- tests/unit/selectmenu/selectmenu_methods.js | 13 ++++++++----- tests/unit/selectmenu/selectmenu_options.js | 2 +- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/tests/unit/selectmenu/selectmenu_core.js b/tests/unit/selectmenu/selectmenu_core.js index 69112054a..40f37e740 100644 --- a/tests/unit/selectmenu/selectmenu_core.js +++ b/tests/unit/selectmenu/selectmenu_core.js @@ -3,13 +3,14 @@ module( "selectmenu: core" ); test("accessibility", function () { - var element = $('#speed').selectmenu(), + var links, + element = $('#speed').selectmenu(), button = element.selectmenu("widget"), menu = element.selectmenu("menuWidget"), selected = element.find("option:selected"); button.simulate( "focus" ); - var links = menu.find("li.ui-menu-item a"); + links = menu.find("li.ui-menu-item a"); expect(12 + links.length * 2); @@ -46,13 +47,14 @@ $.each([ test("state synchronization - " + settings.type, function () { expect(8); - var element = $(settings.selector).selectmenu(), + var links, + element = $(settings.selector).selectmenu(), button = element.selectmenu("widget"), menu = element.selectmenu("menuWidget"), selected = element.find("option:selected"); - button.simulate( "focus" ) - var links = menu.find("li.ui-menu-item a"); + button.simulate( "focus" ); + links = menu.find("li.ui-menu-item a"); button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); equal( menu.attr("aria-activedescendant"), links.eq(element[0].selectedIndex).attr("id"), "after keydown menu aria-activedescendant" ); diff --git a/tests/unit/selectmenu/selectmenu_events.js b/tests/unit/selectmenu/selectmenu_events.js index d8ffecbfb..eb15fea0a 100644 --- a/tests/unit/selectmenu/selectmenu_events.js +++ b/tests/unit/selectmenu/selectmenu_events.js @@ -46,7 +46,9 @@ test("close", function () { test("focus", function () { expect(4); - var counter = 0; + var counter = 0, + button, + menu; this.element.selectmenu({ focus: function (event, ui) { @@ -60,8 +62,8 @@ test("focus", function () { } }); - var button = this.element.selectmenu("widget").parent(), - menu = this.element.selectmenu("menuWidget").parent(); + button = this.element.selectmenu("widget").parent(); + menu = this.element.selectmenu("menuWidget").parent(); button.find("a").simulate( "focus" ).simulate( "click" ); menu.find(".ui-menu-item").simulate("mouseover"); diff --git a/tests/unit/selectmenu/selectmenu_methods.js b/tests/unit/selectmenu/selectmenu_methods.js index 8a048e777..9d84e4787 100644 --- a/tests/unit/selectmenu/selectmenu_methods.js +++ b/tests/unit/selectmenu/selectmenu_methods.js @@ -89,7 +89,8 @@ test("refresh - disabled select", function () { test("refresh - disabled option", function () { expect(1); - var element = $('#speed').selectmenu(), + var disabledItem, + element = $('#speed').selectmenu(), button = element.selectmenu("widget").parent(), menu = element.selectmenu("menuWidget").parent(); @@ -97,14 +98,16 @@ test("refresh - disabled option", function () { element.find("option").eq(2).attr("disabled", "disabled"); element.selectmenu("refresh"); - var disabledItem = menu.find("li").not(".ui-selectmenu-optgroup").eq(2); + disabledItem = menu.find("li").not(".ui-selectmenu-optgroup").eq(2); ok( disabledItem.hasClass("ui-state-disabled"), "class" ); }); test("refresh - disabled optgroup", function () { - var element = $('#files').selectmenu(), + var i, + item, + element = $('#files').selectmenu(), button = element.selectmenu("widget").parent(), menu = element.selectmenu("menuWidget").parent(), originalDisabledOptgroup = element.find("optgroup").first(), @@ -115,11 +118,11 @@ test("refresh - disabled optgroup", function () { originalDisabledOptgroup.attr("disabled", "disabled"); element.selectmenu("refresh"); - var item = menu.find("li.ui-selectmenu-optgroup").first(); + item = menu.find("li.ui-selectmenu-optgroup").first(); ok( item.hasClass("ui-state-disabled"), "class" ); equal( menu.find("li").not(".ui-selectmenu-optgroup").filter(".ui-state-disabled").length, originalDisabledOptions.length, "disabled options" ); - for ( var i = 0; i < originalDisabledOptions.length; i++ ) { + for ( i = 0; i < originalDisabledOptions.length; i++ ) { item = item.next("li"); ok( item.hasClass("ui-state-disabled"), "item #" + i + ": class" ); } diff --git a/tests/unit/selectmenu/selectmenu_options.js b/tests/unit/selectmenu/selectmenu_options.js index e81395940..440df04be 100644 --- a/tests/unit/selectmenu/selectmenu_options.js +++ b/tests/unit/selectmenu/selectmenu_options.js @@ -5,7 +5,7 @@ module("selectmenu: options"); test("appendTo another element", function () { expect(2); - element = $("#speed").selectmenu(); + var element = $("#speed").selectmenu(); ok(element.selectmenu("option", "appendTo", "#qunit-fixture"), "appendTo accepts selector"); ok($("#qunit-fixture").find(".ui-selectmenu-menu").length, "selectmenu appendedTo other element");