aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/position
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2012-04-19 09:39:21 -0400
committerScott González <scott.gonzalez@gmail.com>2012-04-19 09:39:21 -0400
commitaa187f57d16aae5cf5181cd967a385439b09c2ce (patch)
treeae18d23dce8ad710f84b6733ea3f59fbd6dc4dbb /tests/unit/position
parent4f19289c10e733a07cf60435c2e5df4ed2e23d37 (diff)
downloadjquery-ui-aa187f57d16aae5cf5181cd967a385439b09c2ce.tar.gz
jquery-ui-aa187f57d16aae5cf5181cd967a385439b09c2ce.zip
Tests: Lint
Diffstat (limited to 'tests/unit/position')
-rw-r--r--tests/unit/position/position_core.js40
-rw-r--r--tests/unit/position/position_core_within.js133
2 files changed, 84 insertions, 89 deletions
diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js
index fbcac4b7f..5c86e7887 100644
--- a/tests/unit/position/position_core.js
+++ b/tests/unit/position/position_core.js
@@ -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' );
});
diff --git a/tests/unit/position/position_core_within.js b/tests/unit/position/position_core_within.js
index 9dc91238f..187408c61 100644
--- a/tests/unit/position/position_core_within.js
+++ b/tests/unit/position/position_core_within.js
@@ -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' );