Tests: Lint

This commit is contained in:
Scott González 2012-04-19 09:39:21 -04:00
parent 4f19289c10
commit aa187f57d1
7 changed files with 114 additions and 118 deletions

View File

@ -361,6 +361,7 @@ grunt.initConfig({
menu_click: true,
menu_log: true,
module: true,
notEqual: true,
ok: true,
QUnit: true,
spinner_simulateKeyDownUp: true,

View 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 ) {

View 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();
}
});
}

View 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");
});

View 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 );
});

View 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' );
});

View 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' );