]> source.dussan.org Git - jquery-ui.git/commitdiff
Tests: Lint
authorScott González <scott.gonzalez@gmail.com>
Thu, 19 Apr 2012 13:39:21 +0000 (09:39 -0400)
committerScott González <scott.gonzalez@gmail.com>
Thu, 19 Apr 2012 13:39:21 +0000 (09:39 -0400)
grunt.js
tests/unit/effects/effects_core.js
tests/unit/effects/effects_scale.js
tests/unit/menu/menu_core.js
tests/unit/menu/menu_events.js
tests/unit/position/position_core.js
tests/unit/position/position_core_within.js

index 0295b399c9ce06c43c7f756bb1dc10a2b871506b..bc9084e4d3d10f3a6f6c00e49e03081780add55c 100644 (file)
--- a/grunt.js
+++ b/grunt.js
@@ -361,6 +361,7 @@ grunt.initConfig({
                                        menu_click: true,
                                        menu_log: true,
                                        module: true,
+                                       notEqual: true,
                                        ok: true,
                                        QUnit: true,
                                        spinner_simulateKeyDownUp: true,
index aca4c469486ccc688a541b2de8861ab84abe565f..93c7da1141f29956ad71aed67a0afa855a4229e7 100644 (file)
@@ -99,7 +99,7 @@ asyncTest( "animateClass clears style properties when stopped", function() {
        var test = $("div.animateClass"),
                style = test[0].style,
                orig = style.cssText;
-       
+
        expect( 2 );
 
        test.addClass( "testChangeBackground", duration );
@@ -113,17 +113,17 @@ asyncTest( "animateClass clears style properties when stopped", function() {
 asyncTest( "animateClass: css and class changes during animation are not lost (#7106)", function() {
        var test = $( "div.ticket7106" );
 
-       // add a class and change a style property after starting an animated class
-       test.addClass( "animate", minDuration, animationComplete )
-               .addClass( "testClass" )
-               .height( 100 );
-
        // ensure the class stays and that the css property stays
        function animationComplete() {
                ok( test.hasClass( "testClass" ), "class change during animateClass was not lost" );
                equal( test.height(), 100, "css change during animateClass was not lost" );
                start();
        }
+
+       // add a class and change a style property after starting an animated class
+       test.addClass( "animate", minDuration, animationComplete )
+               .addClass( "testClass" )
+               .height( 100 );
 });
 
 
@@ -133,10 +133,9 @@ $.each( $.effects.effect, function( effect ) {
        }
        module( "effect."+effect );
        asyncTest( "show/hide", function() {
-               var hidden = $( "div.hidden" );
                expect( 8 );
-
-               var count = 0,
+               var hidden = $( "div.hidden" ),
+                       count = 0,
                        test = 0;
 
                function queueTest( fn ) {
index b9bb91c2e8f79ca090d625132d3a3e58e70fe020..df61d9e9154d9a71b69faf5c3c14a68e49de4965 100644 (file)
@@ -4,6 +4,11 @@ module( "effect.scale: Scale" );
 function run( position, v, h, vo, ho ) {
        var desc = "End Position Correct: " + position + " (" + v + "," + h + ") - origin: (" + vo + "," + ho + ")";
        asyncTest( desc, function() {
+               function complete() {
+                       equal( parseInt( test.css( h ), 10 ), target[ h ], "Horizontal Position Correct " + desc );
+                       equal( parseInt( test.css( v ), 10 ), target[ v ], "Vertical Position Correct " + desc );
+                       start();
+               }
                var test = $( ".testScale" ),
                        css = {
                                position: position
@@ -21,22 +26,16 @@ function run( position, v, h, vo, ho ) {
 
                css[ h ] = 33;
                css[ v ] = 33;
-               target[ h ] = h === ho ? css[ h ] : ho == "center" ? css[ h ] - 35 : css[ h ] - 70;
-               target[ v ] = v === vo ? css[ v ] : vo == "middle" ? css[ v ] - 35 : css[ v ] - 70;
-               if ( relative && h == "right" ) {
+               target[ h ] = h === ho ? css[ h ] : ho === "center" ? css[ h ] - 35 : css[ h ] - 70;
+               target[ v ] = v === vo ? css[ v ] : vo === "middle" ? css[ v ] - 35 : css[ v ] - 70;
+               if ( relative && h === "right" ) {
                        target[ h ] += 70;
                }
-               if ( relative && v == "bottom" ) {
+               if ( relative && v === "bottom" ) {
                        target[ v ] += 70;
                }
                test.css( css );
                test.effect( effect );
-
-               function complete() {
-                       equal( parseInt( test.css( h ), 10 ), target[ h ], "Horizontal Position Correct " + desc );
-                       equal( parseInt( test.css( v ), 10 ), target[ v ], "Vertical Position Correct " + desc );
-                       start();
-               }
        });
 }
 
index 02e3be3be2e35cc1c098f76d85e22a64acdab9d1..f2de7ef1aae7b6035dfe249deedd84a198d5aa39 100644 (file)
@@ -9,18 +9,19 @@ module("menu: core");
 
 test("accessibility", function () {
        expect(5);
-       var menu = $('#menu1').menu();
-       var item0 = $("li:eq(0) a");
+       var item,
+               menu = $('#menu1').menu(),
+               item0 = $("li:eq(0) a");
 
        ok( menu.hasClass("ui-menu ui-widget ui-widget-content ui-corner-all"), "menu class");
        equal( menu.attr("role"), "menu", "main role");
        ok( !menu.attr("aria-activedescendant"), "aria attribute not yet active");
 
-       var item = menu.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end();
+       item = menu.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end();
        menu.menu( "focus", $.Event(), item );
        equal( menu.attr("aria-activedescendant"), "xid", "aria attribute, id from dom");
 
-       var item = menu.find( "li:last" );
+       item = menu.find( "li:last" );
        menu.menu( "focus", $.Event(), item );
        equal( menu.attr("aria-activedescendant"), "menu1-4", "aria attribute, generated id");
 });
index bee6fcfa62b652bb96f55c13d4a090cb56a914a7..c8203d37c42c48e734c5b819f2a231a3e676841b 100644 (file)
@@ -86,9 +86,6 @@ asyncTest( "handle submenu auto collapse: mouseleave", function() {
        expect( 4 );
        var $menu = $( "#menu2" ).menu();
 
-       $menu.find( "li:nth-child(7)" ).trigger( "mouseover" );
-       setTimeout( menumouseleave1, 350 );
-
        function menumouseleave1() {
                equal( $menu.find( "ul[aria-expanded='true']" ).length, 1, "first submenu expanded" );
                $menu.find( "li:nth-child(7) li:first" ).trigger( "mouseover" );
@@ -108,15 +105,15 @@ asyncTest( "handle submenu auto collapse: mouseleave", function() {
                equal( $menu.find( "ul[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
                start();
        }
+
+       $menu.find( "li:nth-child(7)" ).trigger( "mouseover" );
+       setTimeout( menumouseleave1, 350 );
 });
 
 asyncTest( "handle submenu auto collapse: mouseleave", function() {
        expect( 4 );
        var $menu = $( "#menu5" ).menu( { menus: "div" } );
 
-       $menu.find( ":nth-child(7)" ).trigger( "mouseover" );
-       setTimeout( menumouseleave1, 350 );
-
        function menumouseleave1() {
                equal( $menu.find( "div[aria-expanded='true']" ).length, 1, "first submenu expanded" );
                $menu.find( ":nth-child(7)" ).find( "div" ).eq( 0 ).children().eq( 0 ).trigger( "mouseover" );
@@ -136,6 +133,10 @@ asyncTest( "handle submenu auto collapse: mouseleave", function() {
                equal( $menu.find( "div[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
                start();
        }
+
+       $menu.find( ":nth-child(7)" ).trigger( "mouseover" );
+       setTimeout( menumouseleave1, 350 );
+
 });
 
 
index fbcac4b7f819b7c2ca5f98c9e34041f95e994211..5c86e7887616e3ebbbddeebf658a246891673a70 100644 (file)
@@ -42,31 +42,32 @@ test( "my, at, of", function() {
 });
 
 test( "multiple elements", function() {
-       var elements = $( "#el1, #el2" );
-       var result = elements.position({
-               my: "left top",
-               at: "left bottom",
-               of: "#parent",
-               collision: "none"
-       });
+       var elements = $( "#el1, #el2" ),
+               result = elements.position({
+                       my: "left top",
+                       at: "left bottom",
+                       of: "#parent",
+                       collision: "none"
+               }),
+               expected = { top: 10, left: 4 };
 
        deepEqual( result, elements );
-       var expected = { top: 10, left: 4 };
        elements.each(function() {
                deepEqual( $( this ).offset(), expected );
        });
 });
 
 test( "positions", function() {
-       var definitions = [];
-       var offsets = {
-               left: 0,
-               center: 3,
-               right: 6,
-               top: 0,
-               bottom: 6
-       };
-       var start = { left: 4, top: 4 };
+       var definitions = [],
+               offsets = {
+                       left: 0,
+                       center: 3,
+                       right: 6,
+                       top: 0,
+                       bottom: 6
+               },
+               start = { left: 4, top: 4 },
+               el = $( "#el1" );
        $.each( [ 0, 1 ], function( my ) {
                $.each( [ "top", "center", "bottom" ], function( vindex, vertical ) {
                        $.each( [ "left", "center", "right" ], function( hindex, horizontal ) {
@@ -81,7 +82,6 @@ test( "positions", function() {
                        });
                });
        });
-       var el = $( "#el1" );
        $.each( definitions, function( index, definition ) {
                el.position({
                        my: definition.my,
@@ -445,12 +445,12 @@ test( "addClass: flipped left", function() {
 
        deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Has ui-flipped-left class' );
 
-       elem.position( {
+       elem.position({
                my: "right center",
                of: window,
                collision: "flip",
                at: "left center"
-       })
+       });
 
        deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Removed ui-flipped-left class' );
 });
index 9dc91238f93ce361357da54eb514dc1b1e1021bb..187408c619925b4d81c59513415f42b17051a718 100644 (file)
@@ -65,32 +65,33 @@ test( "my, at, of", function() {
 });
 
 test( "multiple elements", function() {
-       var elements = $( "#el1, #el2" );
-       var result = elements.position({
-               my: "left top",
-               at: "left bottom",
-               of: "#parent",
-               collision: "none",
-               within: $("#within-container")
-       });
+       var elements = $( "#el1, #el2" ),
+               result = elements.position({
+                       my: "left top",
+                       at: "left bottom",
+                       of: "#parent",
+                       collision: "none",
+                       within: $("#within-container")
+               }),
+               expected = { top: addTop + 10, left: addLeft + 4 };
 
        deepEqual( result, elements );
-       var expected = { top: addTop + 10, left: addLeft + 4 };
        elements.each(function() {
                deepEqual( $( this ).addOffsets(), expected );
        });
 });
 
 test( "positions", function() {
-       var definitions = [];
-       var offsets = {
-               left: 0,
-               center: 3,
-               right: 6,
-               top: 0,
-               bottom: 6
-       };
-       var start = { left: 4, top: 4 };
+       var definitions = [],
+               offsets = {
+                       left: 0,
+                       center: 3,
+                       right: 6,
+                       top: 0,
+                       bottom: 6
+               },
+               start = { left: 4, top: 4 },
+               el = $( "#el1" );
        $.each( [ 0, 1 ], function( my ) {
                $.each( [ "top", "center", "bottom" ], function( vindex, vertical ) {
                        $.each( [ "left", "center", "right" ], function( hindex, horizontal ) {
@@ -105,7 +106,6 @@ test( "positions", function() {
                        });
                });
        });
-       var el = $( "#el1" );
        $.each( definitions, function( index, definition ) {
                el.position({
                        my: definition.my,
@@ -120,7 +120,8 @@ test( "positions", function() {
 });
 
 test( "of", function() {
-       var within = $("#within-container");
+       var event,
+               within = $( "#within-container" );
 
        $( "#elx" ).position({
                my: "left top",
@@ -149,7 +150,7 @@ test( "of", function() {
        });
        deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "DOM element" );
 
-       var event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } );
+       event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } );
        $( "#elx" ).position({
                my: "left top",
                at: "left top",
@@ -219,9 +220,8 @@ test( "within:offsets", function() {
 test( "using", function() {
        expect( 6 );
 
-       var within = $("#within-container");
-
-       var count = 0,
+       var within = $( "#within-container" ),
+               count = 0,
                elems = $( "#el1, #el2" ),
                expectedPosition = { top: addTop + 40, left: addLeft + 40 },
                originalPosition = elems.position({
@@ -252,14 +252,13 @@ test( "using", function() {
 });
 
 function collisionTest( config, result, msg ) {
-       var within = $("#within-container");
-
-       var elem = $( "#elx" ).position( $.extend({
-               my: "left top",
-               at: "right bottom",
-               of: "#parentx",
-               within: within
-       }, config ) );
+       var within = $( "#within-container" ),
+               elem = $( "#elx" ).position( $.extend({
+                       my: "left top",
+                       at: "right bottom",
+                       of: "#parentx",
+                       within: within
+               }, config ) );
 
        deepEqual( elem.addOffsets(), result, msg );
 }
@@ -448,39 +447,37 @@ test( "collision: flip, with margin", function() {
 });
 
 test( "addClass: flipped left", function() {
-       var within = $("#within-container");
-
-       var elem = $( "#elx" ).position( {
-               my: "left center",
-               of: within[0],
-               within: within,
-               collision: "flip",
-               at: "right center"
-       });
+       var within = $("#within-container"),
+               elem = $( "#elx" ).position( {
+                       my: "left center",
+                       of: within[0],
+                       within: within,
+                       collision: "flip",
+                       at: "right center"
+               });
 
        deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Has ui-flipped-left class' );
 
-       elem.position( {
+       elem.position({
                my: "right center",
                of: within[0],
                within: within,
                collision: "flip",
                at: "left center"
-       })
+       });
 
        deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Removed ui-flipped-left class' );
 });
 
 test( "addClass: flipped top", function() {
-       var within = $("#within-container");
-
-       var elem = $( "#elx" ).position( {
-               my: "left top",
-               of: within[0],
-               within: within,
-               collision: "flip",
-               at: "right bottom"
-       });
+       var within = $("#within-container"),
+               elem = $( "#elx" ).position( {
+                       my: "left top",
+                       of: within[0],
+                       within: within,
+                       collision: "flip",
+                       at: "right bottom"
+               });
 
        deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Has ui-flipped-top class' );
 
@@ -496,15 +493,14 @@ test( "addClass: flipped top", function() {
 });
 
 test( "addClass: flipped right", function() {
-       var within = $("#within-container");
-
-       var elem = $( "#elx" ).position( {
-               my: "right center",
-               of: within[0],
-               within: within,
-               collision: "flip",
-               at: "left center"
-       });
+       var within = $("#within-container"),
+               elem = $( "#elx" ).position( {
+                       my: "right center",
+                       of: within[0],
+                       within: within,
+                       collision: "flip",
+                       at: "left center"
+               });
 
        deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Has ui-flipped-right class' );
 
@@ -521,14 +517,13 @@ test( "addClass: flipped right", function() {
 });
 
 test( "addClass: flipped bottom", function() {
-       var within = $("#within-container");
-
-       var elem = $( "#elx" ).position( {
-               my: "left bottom",
-               of: window,
-               collision: "flip",
-               at: "right top"
-       });
+       var within = $("#within-container"),
+               elem = $( "#elx" ).position( {
+                       my: "left bottom",
+                       of: window,
+                       collision: "flip",
+                       at: "right top"
+               });
 
        deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Has ui-flipped-bottom class' );