aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMike Sherov <mike.sherov@gmail.com>2014-08-14 21:03:18 -0400
committerMike Sherov <mike.sherov@gmail.com>2014-08-14 21:03:18 -0400
commit01e26b0f5388a855ad86d40e1284c9c79a9abd3b (patch)
treea7c5f3ef6bbef14fb27ad4e11f21c64b0c057d50 /tests
parent2d03839c07a33d14ec7b31b2d4290a8ce6fc0cef (diff)
downloadjquery-ui-01e26b0f5388a855ad86d40e1284c9c79a9abd3b.tar.gz
jquery-ui-01e26b0f5388a855ad86d40e1284c9c79a9abd3b.zip
Draggable Tests: Clarify position helper test generation
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/draggable/draggable_options.js87
1 files changed, 44 insertions, 43 deletions
diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js
index 4f319e404..03a9bf355 100644
--- a/tests/unit/draggable/draggable_options.js
+++ b/tests/unit/draggable/draggable_options.js
@@ -671,10 +671,42 @@ test( "helper, default, switching after initialization", function() {
TestHelpers.draggable.shouldMove( element, "helper: original" );
});
-/* jshint loopfunc: true */
+function testHelperPosition( scrollPositions, position, helper, scrollElements, scrollElementsTitle ) {
+ test( "{ helper: '" + helper + "' }, " + position + ", with scroll offset on " + scrollElementsTitle, function() {
+ expect( scrollPositions.length * 2 );
+
+ var i, j,
+ element = $( "#draggable1" ).css({ position: position, top: 0, left: 0 }).draggable({
+ helper: helper,
+ scroll: false
+ });
+
+ if ( scrollElements.length === 1 && scrollElements[ 0 ] === "#scrollParent" ) {
+ TestHelpers.draggable.setScrollable( "#main", false );
+ TestHelpers.draggable.setScrollable( "#scrollParent", true );
+ }
+
+ for ( j = 0; j < scrollPositions.length; j++ ) {
+ for ( i = 0; i < scrollElements.length; i++ ) {
+ TestHelpers.draggable.setScroll( scrollElements[ i ] );
+ }
+
+ TestHelpers.draggable.testScroll( element, scrollPositions[ j ] );
+
+ for ( i = 0; i < scrollElements.length; i++ ) {
+ TestHelpers.draggable.restoreScroll( scrollElements[ i ] );
+ }
+ }
+
+ if ( scrollElements.length === 1 && scrollElements[ 1 ] === "#scrollParent" ) {
+ TestHelpers.draggable.setScrollable( "#main", true );
+ TestHelpers.draggable.setScrollable( "#scrollParent", false );
+ }
+ });
+}
+
(function() {
- var k, l, m,
- scrollElements = {
+ var scrollElementsMap = {
"no elements": [],
"parent": [ "#main" ],
"root": [ document ],
@@ -686,47 +718,16 @@ test( "helper, default, switching after initialization", function() {
// static is not an option here since the fixture is in an absolute container
scrollPositions = [ "relative", "absolute", "fixed" ];
- for ( m = 0 ; m < helpers.length; m++ ) {
- for ( l = 0; l < positions.length; l++ ) {
- for ( k in scrollElements ) {
- (function( position, helper, scrollElements, scrollElementsTitle ) {
- test( "{ helper: '" + helper + "' }, " + position + ", with scroll offset on " + scrollElementsTitle, function() {
- expect( scrollPositions.length * 2 );
-
- var i, j,
- element = $( "#draggable1" ).css({ position: position, top: 0, left: 0 }).draggable({
- helper: helper,
- scroll: false
- });
-
- if ( scrollElements.length === 1 && scrollElements[ 0 ] === "#scrollParent" ) {
- TestHelpers.draggable.setScrollable( "#main", false );
- TestHelpers.draggable.setScrollable( "#scrollParent", true );
- }
-
- for ( j = 0; j < scrollPositions.length; j++ ) {
- for ( i = 0; i < scrollElements.length; i++ ) {
- TestHelpers.draggable.setScroll( scrollElements[ i ] );
- }
-
- TestHelpers.draggable.testScroll( element, scrollPositions[ j ] );
-
- for ( i = 0; i < scrollElements.length; i++ ) {
- TestHelpers.draggable.restoreScroll( scrollElements[ i ] );
- }
- }
-
- if ( scrollElements.length === 1 && scrollElements[ 1 ] === "#scrollParent" ) {
- TestHelpers.draggable.setScrollable( "#main", true );
- TestHelpers.draggable.setScrollable( "#scrollParent", false );
- }
- });
- })( positions[ l ], helpers[ m ], scrollElements[ k ], k );
- }
- }
- }
+ $.each( helpers, function() {
+ var helper = this;
+ $.each( positions, function() {
+ var position = this;
+ $.each( scrollElementsMap, function( scrollElementsTitle, scrollElements ) {
+ testHelperPosition( scrollPositions, position, helper, scrollElements, scrollElementsTitle );
+ });
+ });
+ });
})();
-/* jshint loopfunc: false */
test( "{ opacity: 0.5 }", function() {
expect( 1 );