diff --git a/.mailmap b/.mailmap new file mode 100644 index 000000000..e130cc4bb --- /dev/null +++ b/.mailmap @@ -0,0 +1,6 @@ +Kris Borchers +Kris Borchers +Corey Frang +Maggie Costello Wachs maggiewachs +Richard Worth +Jörn Zaefferer diff --git a/AUTHORS.txt b/AUTHORS.txt index bc7c89d79..2a7a396c8 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -231,3 +231,8 @@ Pavel Selitskas Bjørn Johansen Matthieu Penant Dominic Barnes +David Sullivan +Thomas Jaggi +Vahid Sohrabloo +Travis Carden +Bruno M. Custódio diff --git a/build/release/release.js b/build/release/release.js index 3470b6575..2eab5283f 100644 --- a/build/release/release.js +++ b/build/release/release.js @@ -121,7 +121,7 @@ function getVersions() { // TODO: handle 1.10.0 // Also see comment above about pre-releases - if ( minor === 0 ) { + if ( patch === 0 ) { abort( "This script is not smart enough to handle the 1.10.0 release." ); } diff --git a/build/tasks/build.js b/build/tasks/build.js index 18e427a56..a8f25f98f 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -159,7 +159,7 @@ grunt.registerMultiTask( "zip", "Create a zip file for release", function() { grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", function() { // remove dest file before creating it, to make sure itself is not included - if ( path.existsSync( this.file.dest ) ) { + if ( fs.existsSync( this.file.dest ) ) { fs.unlinkSync( this.file.dest ); } var crypto = require( "crypto" ), @@ -175,62 +175,43 @@ grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", fun }); grunt.registerTask( "generate_themes", function() { - var download, files, done, - target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/", - distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() ); + var download, done, + distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() ), + target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/"; + try { require.resolve( "download.jqueryui.com" ); } catch( error ) { throw new Error( "You need to manually install download.jqueryui.com for this task to work" ); } - // copy release files into download builder to avoid cloning again - grunt.file.expandFiles( distFolder + "/**" ).forEach(function( file ) { - grunt.file.copy( file, "node_modules/download.jqueryui.com/release/" + file.replace(/^dist/, "") ); - }); - - download = new ( require( "download.jqueryui.com" ) )(); - - files = grunt.file.expandFiles( distFolder + "/themes/base/**/*" ); - files.forEach(function( fileName ) { - grunt.file.copy( fileName, target + fileName.replace( distFolder, "" ) ); + download = require( "download.jqueryui.com" )({ + config: { + "jqueryUi": { + "stable": { "path": path.resolve( __dirname + "/../../" + distFolder ) } + }, + "jquery": "skip" + } }); done = this.async(); - grunt.utils.async.forEach( download.themeroller.gallery(), function( theme, done ) { - var folderName = theme.folderName(), - concatTarget = "css-" + folderName, - cssContent = theme.css(), - cssFolderName = target + "themes/" + folderName + "/", - cssFileName = cssFolderName + "jquery.ui.theme.css", - cssFiles = grunt.config.get( "concat.css.src" )[ 1 ].slice(); - - grunt.file.write( cssFileName, cssContent ); - - // get css components, replace the last file with the current theme - cssFiles.splice(-1); - cssFiles.push( "" ); - grunt.config.get( "concat" )[ concatTarget ] = { - src: [ "", cssFiles ], - dest: cssFolderName + "jquery-ui.css" - }; - grunt.task.run( "concat:" + concatTarget ); - - theme.fetchImages(function( err, files ) { - if ( err ) { - done( err ); - return; - } - files.forEach(function( file ) { - grunt.file.write( cssFolderName + "images/" + file.path, file.data ); - }); - done(); - }); - }, function( err ) { - if ( err ) { - grunt.log.error( err ); + download.buildThemesBundle(function( error, files ) { + if ( error ) { + grunt.log.error( error ); + return done( false ); } - done( !err ); + + done( + files.every(function( file ) { + try { + grunt.file.write( target + file.path, file.data ); + } catch( err ) { + grunt.log.error( err ); + return false; + } + return true; + }) && grunt.log.writeln( "Generated at " + target ) + ); }); }); diff --git a/build/tasks/testswarm.js b/build/tasks/testswarm.js index 8e88007bb..3361b7fa9 100644 --- a/build/tasks/testswarm.js +++ b/build/tasks/testswarm.js @@ -4,6 +4,7 @@ module.exports = function( grunt ) { var versions = { "git": "git", + "1.9": "1.9.0 1.9.1", "1.8": "1.8.0 1.8.1 1.8.2 1.8.3", "1.7": "1.7 1.7.1 1.7.2", "1.6": "1.6 1.6.1 1.6.2 1.6.3 1.6.4" @@ -32,30 +33,37 @@ var versions = { "Widget": "widget/widget.html" }; -function submit( commit, tests, configFile, version, done ) { - var test, +function submit( commit, runs, configFile, version, done ) { + var testName, testswarm = require( "testswarm" ), - config = grunt.file.readJSON( configFile ).jqueryui, - testBase = config.testUrl + commit + "/tests/unit/", - testUrls = []; - for ( test in tests ) { - testUrls.push( testBase + tests[ test ] ); - } + config = grunt.file.readJSON( configFile ).jqueryui; version = version ? ( version + " " ) : ""; - testswarm({ + for ( testName in runs ) { + runs[ testName] = config.testUrl + commit + "/tests/unit/" + runs[ testName ]; + } + testswarm.createClient( { url: config.swarmUrl, pollInterval: 10000, - timeout: 1000 * 60 * 45, - done: done - }, { - authUsername: config.authUsername, - authToken: config.authToken, - jobName: 'jQuery UI ' + version + '#' + commit.substr( 0, 10 ) + '', - runMax: config.runMax, - "runNames[]": Object.keys( tests ), - "runUrls[]": testUrls, - "browserSets[]": config.browserSets - }); + timeout: 1000 * 60 * 45 + } ) + .addReporter( testswarm.reporters.cli ) + .auth( { + id: config.authUsername, + token: config.authToken + } ) + .addjob( + { + name: 'jQuery UI ' + version + '#' + commit.substr( 0, 10 ) + '', + runs: runs, + runMax: config.runMax, + browserSets: config.browserSets + }, function( err, passed ) { + if ( err ) { + grunt.log.error( err ); + } + done( passed ); + } + ); } grunt.registerTask( "testswarm", function( commit, configFile ) { diff --git a/demos/accordion/collapsible.html b/demos/accordion/collapsible.html index 358ff618c..659dfa744 100644 --- a/demos/accordion/collapsible.html +++ b/demos/accordion/collapsible.html @@ -4,7 +4,7 @@ jQuery UI Accordion - Collapse content - + diff --git a/demos/accordion/custom-icons.html b/demos/accordion/custom-icons.html index 56a9d450c..dd5a91ff9 100644 --- a/demos/accordion/custom-icons.html +++ b/demos/accordion/custom-icons.html @@ -4,7 +4,7 @@ jQuery UI Accordion - Customize icons - + diff --git a/demos/accordion/default.html b/demos/accordion/default.html index 311717a40..c3bcfddf3 100644 --- a/demos/accordion/default.html +++ b/demos/accordion/default.html @@ -4,7 +4,7 @@ jQuery UI Accordion - Default functionality - + diff --git a/demos/accordion/fillspace.html b/demos/accordion/fillspace.html index 1e7df6596..49f92fb11 100644 --- a/demos/accordion/fillspace.html +++ b/demos/accordion/fillspace.html @@ -4,7 +4,7 @@ jQuery UI Accordion - Fill space - + diff --git a/demos/accordion/hoverintent.html b/demos/accordion/hoverintent.html index ce195c05f..0ff63a321 100644 --- a/demos/accordion/hoverintent.html +++ b/demos/accordion/hoverintent.html @@ -4,7 +4,7 @@ jQuery UI Accordion - Open on hoverintent - + @@ -16,11 +16,11 @@ }); }); - var cfg = ($.hoverintent = { - sensitivity: 7, - interval: 100 - }); - + /* + * hoverIntent | Copyright 2011 Brian Cherne + * http://cherne.net/brian/resources/jquery.hoverIntent.html + * modified by the jQuery UI team + */ $.event.special.hoverintent = { setup: function() { $( this ).bind( "mouseover", jQuery.event.special.hoverintent.handler ); @@ -29,41 +29,56 @@ $( this ).unbind( "mouseover", jQuery.event.special.hoverintent.handler ); }, handler: function( event ) { - var that = this, + var currentX, currentY, timeout, args = arguments, target = $( event.target ), - cX, cY, pX, pY; + previousX = event.pageX, + previousY = event.pageY; function track( event ) { - cX = event.pageX; - cY = event.pageY; + currentX = event.pageX; + currentY = event.pageY; }; - pX = event.pageX; - pY = event.pageY; + function clear() { target .unbind( "mousemove", track ) - .unbind( "mouseout", arguments.callee ); + .unbind( "mouseout", clear ); clearTimeout( timeout ); } + function handler() { - if ( ( Math.abs( pX - cX ) + Math.abs( pY - cY ) ) < cfg.sensitivity ) { + var prop, + orig = event; + + if ( ( Math.abs( previousX - currentX ) + + Math.abs( previousY - currentY ) ) < 7 ) { clear(); - event.type = "hoverintent"; - // prevent accessing the original event since the new event + + event = $.Event( "hoverintent" ); + for ( prop in orig ) { + if ( !( prop in event ) ) { + event[ prop ] = orig[ prop ]; + } + } + // Prevent accessing the original event since the new event // is fired asynchronously and the old event is no longer // usable (#6028) - event.originalEvent = {}; - jQuery.event.handle.apply( that, args ); + delete event.originalEvent; + + target.trigger( event ); } else { - pX = cX; - pY = cY; - timeout = setTimeout( handler, cfg.interval ); + previousX = currentX; + previousY = currentY; + timeout = setTimeout( handler, 100 ); } } - var timeout = setTimeout( handler, cfg.interval ); - target.mousemove( track ).mouseout( clear ); - return true; + + timeout = setTimeout( handler, 100 ); + target.bind({ + mousemove: track, + mouseout: clear + }); } }; diff --git a/demos/accordion/no-auto-height.html b/demos/accordion/no-auto-height.html index 2edaa10ea..8df94cb71 100644 --- a/demos/accordion/no-auto-height.html +++ b/demos/accordion/no-auto-height.html @@ -4,7 +4,7 @@ jQuery UI Accordion - No auto height - + diff --git a/demos/accordion/sortable.html b/demos/accordion/sortable.html index 56020efbe..4a25f2413 100644 --- a/demos/accordion/sortable.html +++ b/demos/accordion/sortable.html @@ -4,7 +4,7 @@ jQuery UI Accordion - Sortable - + diff --git a/demos/addClass/default.html b/demos/addClass/default.html index a0c1ceb14..97a06a293 100644 --- a/demos/addClass/default.html +++ b/demos/addClass/default.html @@ -4,7 +4,7 @@ jQuery UI Effects - addClass demo - + + @@ -16,7 +22,9 @@ "ui/jquery.ui.core.js", "ui/jquery.ui.widget.js", "ui/jquery.ui.interaction.js", - "ui/jquery.ui.draggable.js" + "ui/jquery.ui.resizable.js", + "ui/jquery.ui.draggable.js", + "ui/jquery.ui.droppable.js" ] }); @@ -38,14 +46,12 @@

    -
    -
    Relative
    Absolute
    +
    Absolute
    -
    diff --git a/tests/unit/draggable/draggable_common.js b/tests/unit/draggable/draggable_common.js index ff01bbc94..428daca8c 100644 --- a/tests/unit/draggable/draggable_common.js +++ b/tests/unit/draggable/draggable_common.js @@ -29,6 +29,12 @@ TestHelpers.commonWidgetTests( "draggable", { zIndex: false, cancel: null, + //todo: remove the following option checks when interactions are rewritten: + addClasses: true, + delay: 0, + distance: 1, + iframeFix: false, + // callbacks beforeStart: null, create: null, diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index ba8b98404..9875a481e 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -126,14 +126,14 @@ test("_blockFrames, relative parent", function() { el.on( "drag", function() { var block = iframe.next(); - + left = block.css("left"); top = block.css("top"); }); TestHelpers.draggable.shouldMove(el); - + equal( left, "30px" ); equal( top, "25px" ); @@ -153,14 +153,14 @@ test("_blockFrames, static parent", function() { el.on( "drag", function() { var block = iframe.next(); - + left = block.css("left"); top = block.css("top"); }); TestHelpers.draggable.shouldMove(el); - + equal( left, "430px" ); equal( top, "325px" ); diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index a51745e7a..c000a136b 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -1,139 +1,124 @@ -/* - * draggable_options.js - */ -(function($) { +(function( $ ) { -module("draggable: options"); +module( "draggable: options" ); // TODO: This doesn't actually test whether append happened, possibly remove -test("{ appendTo: 'parent' }, default, no clone", function() { +test( "{ appendTo: 'parent' }, default, no clone", function() { expect( 2 ); - var el = $("#draggable2").draggable({ appendTo: "parent" }); - TestHelpers.draggable.shouldMove(el); - - el = $("#draggable1").draggable({ appendTo: "parent" }); - TestHelpers.draggable.shouldMove(el); + var element = $( "#draggable2" ).draggable({ appendTo: "parent" }); + TestHelpers.draggable.shouldMove( element ); + element = $( "#draggable1" ).draggable({ appendTo: "parent" }); + TestHelpers.draggable.shouldMove( element ); }); // TODO: This doesn't actually test whether append happened, possibly remove -test("{ appendTo: Element }, no clone", function() { +test( "{ appendTo: Element }, no clone", function() { expect( 2 ); - var el = $("#draggable2").draggable({appendTo: $("#draggable2").parent()[0] }); + var element = $( "#draggable2" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] }); - TestHelpers.draggable.shouldMove(el); + TestHelpers.draggable.shouldMove( element ); - el = $("#draggable1").draggable({ appendTo: $("#draggable2").parent()[0] }); - TestHelpers.draggable.shouldMove(el); + element = $( "#draggable1" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] }); + TestHelpers.draggable.shouldMove( element ); }); // TODO: This doesn't actually test whether append happened, possibly remove -test("{ appendTo: Selector }, no clone", function() { +test( "{ appendTo: Selector }, no clone", function() { expect( 2 ); - var el = $("#draggable2").draggable({ appendTo: "#main" }); - TestHelpers.draggable.shouldMove(el); + var element = $( "#draggable2" ).draggable({ appendTo: "#main" }); + TestHelpers.draggable.shouldMove( element ); - el = $("#draggable1").draggable({ appendTo: "#main" }); - TestHelpers.draggable.shouldMove(el); + element = $( "#draggable1" ).draggable({ appendTo: "#main" }); + TestHelpers.draggable.shouldMove( element ); }); -test("{ appendTo: 'parent' }, default", function() { +test( "{ appendTo: 'parent' }, default", function() { + expect( 2 ); - expect(2); + var element = $( "#draggable1" ).draggable(); - var el = $("#draggable1").draggable(); + TestHelpers.draggable.trackAppendedParent( element ); - TestHelpers.draggable.trackAppendedParent(el); - - equal( el.draggable( "option", "appendTo" ), null ); - - TestHelpers.draggable.move(el, 1, 1); - equal( el.data("last_dragged_parent"), $("#qunit-fixture")[0] ); + equal( element.draggable( "option", "appendTo" ), "parent" ); + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] ); }); -test("{ appendTo: Element }", function() { +test( "{ appendTo: Element }", function() { + expect( 1 ); - expect(1); + var appendTo = $( "#draggable2" ).parent()[ 0 ], + element = $( "#draggable1" ).draggable({ appendTo: appendTo }); - var appendTo = $("#draggable2").parent()[0], - el = $("#draggable1").draggable({ appendTo: appendTo }); - - TestHelpers.draggable.trackAppendedParent(el); - - TestHelpers.draggable.move(el, 1, 1); - equal( el.data("last_dragged_parent"), appendTo ); + TestHelpers.draggable.trackAppendedParent( element ); + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_parent" ), appendTo ); }); -test("{ appendTo: jQuery }", function() { +test( "{ appendTo: jQuery }", function() { + expect( 1 ); - expect(1); + var appendTo = $( "#draggable2" ).parent(), + element = $( "#draggable1" ).draggable({ appendTo: appendTo }); - var appendTo = $("#draggable2").parent(), - el = $("#draggable1").draggable({ appendTo: appendTo }); - - TestHelpers.draggable.trackAppendedParent(el); - - TestHelpers.draggable.move(el, 1, 1); - equal( el.data("last_dragged_parent"), appendTo[0] ); + TestHelpers.draggable.trackAppendedParent( element ); + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_parent" ), appendTo[ 0 ] ); }); -test("{ appendTo: Selector }", function() { - - expect(1); +test( "{ appendTo: Selector }", function() { + expect( 1 ); var appendTo = "#main", - el = $("#draggable1").draggable({ appendTo: appendTo }); + element = $( "#draggable1" ).draggable({ appendTo: appendTo }); - TestHelpers.draggable.trackAppendedParent(el); - - TestHelpers.draggable.move(el, 1, 1); - equal( el.data("last_dragged_parent"), $(appendTo)[0] ); + TestHelpers.draggable.trackAppendedParent( element ); + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_parent" ), $(appendTo)[ 0 ] ); }); +test( "appendTo, default, switching after initialization", function() { + expect( 2 ); -test("appendTo, default, switching after initialization", function() { + var element = $( "#draggable1" ).draggable({ helper : "clone" }); - expect(2); + TestHelpers.draggable.trackAppendedParent( element ); - var el = $("#draggable1").draggable({ helper : "clone" }); - - TestHelpers.draggable.trackAppendedParent(el); - - // Move and make sure el was appended to fixture - TestHelpers.draggable.move(el, 1, 1); - equal( el.data("last_dragged_parent"), $("#qunit-fixture")[0] ); - - // Move and make sure el was appended to main - el.draggable( "option", "appendTo", $("#main") ); - TestHelpers.draggable.move(el, 2, 2); - equal( el.data("last_dragged_parent"), $("#main")[0] ); + // Move and make sure element was appended to fixture + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] ); + // Move and make sure element was appended to main + element.draggable( "option", "appendTo", $( "#main" ) ); + TestHelpers.draggable.move( element, 2, 2 ); + equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] ); }); -test("{ axis: false }, default", function() { +test( "{ axis: false }, default", function() { expect( 1 ); - var el = $("#draggable2").draggable({ axis: false }); - TestHelpers.draggable.shouldMove(el); + var element = $( "#draggable2" ).draggable({ axis: false }); + TestHelpers.draggable.shouldMove( element ); }); -test("{ axis: 'x' }", function() { +test( "{ axis: 'x' }", function() { expect( 1 ); - var el = $("#draggable2").draggable({ axis: "x" }); - TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 0); + var element = $( "#draggable2" ).draggable({ axis: "x" }); + TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 0 ); }); -test("{ axis: 'y' }", function() { +test( "{ axis: 'y' }", function() { expect( 1 ); - var el = $("#draggable2").draggable({ axis: "y" }); - TestHelpers.draggable.testDrag(el, el, 50, 50, 0, 50); + var element = $( "#draggable2" ).draggable({ axis: "y" }); + TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 50 ); }); -test("{ axis: ? }, unexpected", function() { - var el, +test( "{ axis: ? }, unexpected", function() { + var element, unexpected = { "true": true, "{}": {}, @@ -146,63 +131,61 @@ test("{ axis: ? }, unexpected", function() { expect( 6 ); $.each(unexpected, function(key, val) { - el = $("#draggable2").draggable({ axis: val }); - TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50, "axis: " + key); - el.draggable("destroy"); + element = $( "#draggable2" ).draggable({ axis: val }); + TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 50, "axis: " + key ); + element.draggable( "destroy" ); }); }); -test("axis, default, switching after initialization", function() { +test( "axis, default, switching after initialization", function() { + expect( 3 ); - expect(3); + var element = $( "#draggable1" ).draggable({ axis : false }); - var el; - - // Any direction - el = $("#draggable1").draggable({ axis : false }); - TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50); + // Any Direction + TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 50 ); // Only horizontal - el.draggable("option", "axis", "x"); - TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 0); + element.draggable( "option", "axis", "x" ); + TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 0 ); // Vertical only - el.draggable("option", "axis", "y"); - TestHelpers.draggable.testDrag(el, el, 50, 50, 0, 50); + element.draggable( "option", "axis", "y" ); + TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 50 ); }); -test("{ cancel: 'input,textarea,button,select,option' }, default", function() { +test( "{ cancel: 'input,textarea,button,select,option' }, default", function() { expect( 2 ); - $("
    ").appendTo("#main"); + $( "
    " ).appendTo( "#main" ); - var el = $("#draggable-option-cancel-default").draggable({ cancel: "input,textarea,button,select,option" }); - TestHelpers.draggable.shouldMove(el); + var element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" }); + TestHelpers.draggable.shouldMove( element ); - el.draggable("destroy"); + element.draggable( "destroy" ); - el = $("#draggable-option-cancel-default").draggable({ cancel: "input,textarea,button,select,option" }); - TestHelpers.draggable.testDrag(el, "#draggable-option-cancel-default input", 50, 50, 0, 0); - el.draggable("destroy"); + element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" }); + TestHelpers.draggable.testDrag( element, "#draggable-option-cancel-default input", 50, 50, 0, 0 ); + element.draggable( "destroy" ); }); -test("{ cancel: 'span' }", function() { +test( "{ cancel: 'span' }", function() { expect( 2 ); - var el = $("#draggable2").draggable(); - TestHelpers.draggable.testDrag(el, "#draggable2 span", 50, 50, 50, 50); + var element = $( "#draggable2" ).draggable(); + TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 50, 50 ); - el.draggable("destroy"); + element.draggable( "destroy" ); - el = $("#draggable2").draggable({ cancel: "span" }); - TestHelpers.draggable.testDrag(el, "#draggable2 span", 50, 50, 0, 0); + element = $( "#draggable2" ).draggable({ cancel: "span" }); + TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 0, 0 ); }); test( "{ cancel: ? }, unexpected", function() { expect( 6 ); - var el, + var element, unexpected = { "true": true, "false": false, @@ -213,227 +196,248 @@ test( "{ cancel: ? }, unexpected", function() { }; $.each( unexpected, function( key, val ) { - el = $("#draggable2").draggable({ cancel: val }); - TestHelpers.draggable.shouldMove( el, "cancel: " + key ); - el.draggable("destroy"); + element = $( "#draggable2" ).draggable({ cancel: val }); + TestHelpers.draggable.shouldMove( element, "cancel: " + key ); + element.draggable( "destroy" ); }); }); -test("{ cancel: Selectors }, matching parent selector", function() { +/** +test( "{ cancel: Selectors }, matching parent selector", function() { expect( 5 ); - var el = $("#draggable2").draggable({ cancel: "span a" }); - - $("#qunit-fixture").append( "" ); - - el.find( "span" ).append( "" ); - - $("#wrapping a").append( el ); - - TestHelpers.draggable.testDrag(el, "#draggable2 span", 50, 50, 50, 50, "drag span child"); - TestHelpers.draggable.shouldNotMove( $("#draggable2 span a") ); - TestHelpers.draggable.shouldNotMove( $("#wrapping a") ); - - $("#draggable2").draggable( "option", "cancel", "span > a" ); - $("#draggable2").find( "a" ).append( "" ); - - - TestHelpers.draggable.testDrag(el, $("#draggable2 span a").last(), 50, 50, 50, 50, "drag span child"); - TestHelpers.draggable.shouldNotMove( $("#draggable2 span a").first() ); - + var element = $( "#draggable2" ).draggable({ cancel: "span a" }); + + $( "#qunit-fixture" ).append( "" ); + + element.find( "span" ).append( "" ); + + $( "#wrapping a" ).append( element ); + + TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 50, 50, "drag span child" ); + TestHelpers.draggable.shouldNotMove( $( "#draggable2 span a" ) ); + TestHelpers.draggable.shouldNotMove( $( "#wrapping a" ) ); + + $( "#draggable2" ).draggable( "option", "cancel", "span > a" ); + $( "#draggable2" ).find( "a" ).append( "" ); + + + TestHelpers.draggable.testDrag( element, $( "#draggable2 span a" ).last(), 50, 50, 50, 50, "drag span child" ); + TestHelpers.draggable.shouldNotMove( $( "#draggable2 span a" ).first() ); + }); +*/ - -test("cancel, default, switching after initialization", function() { +test( "cancelement, default, switching after initialization", function() { expect( 3 ); - $("
    ").appendTo("#main"); + $( "
    " ).appendTo( "#main" ); - var input = $("#draggable-option-cancel-default input"), - el = $("#draggable-option-cancel-default").draggable(); + var input = $( "#draggable-option-cancel-default input" ), + element = $( "#draggable-option-cancel-default" ).draggable(); - TestHelpers.draggable.testDrag(el, input, 50, 50, 0, 0); + TestHelpers.draggable.testDrag( element, input, 50, 50, 0, 0 ); - el.draggable("option", "cancel", "textarea" ); - TestHelpers.draggable.testDrag(el, input, 50, 50, 50, 50); - - el.draggable("option", "cancel", "input" ); - TestHelpers.draggable.testDrag(el, input, 50, 50, 0, 0); + element.draggable( "option", "cancel", "textarea" ); + TestHelpers.draggable.testDrag( element, input, 50, 50, 50, 50 ); + element.draggable( "option", "cancel", "input" ); + TestHelpers.draggable.testDrag( element, input, 50, 50, 0, 0 ); }); /* -test("{ containment: false }, default", function() { + +test( "{ connectToSortable: selector }, default", function() { expect( 1 ); - ok(false, "missing test - untested code is broken code"); -}); - -test("{ containment: Element }", function() { - expect( 1 ); - - ok(false, "missing test - untested code is broken code"); + ok(false, "missing test - untested code is broken code" ); }); */ -test("{ containment: 'parent' }, relative", function() { +test( "{ containment: Element }", function() { expect( 1 ); var offsetAfter, - el = $("#draggable1").draggable({ containment: "parent" }), - p = el.parent(), + element = $( "#draggable1" ).draggable({ containment: $( "#draggable1" ).parent()[ 0 ] }), + p = element.parent(), po = p.offset(), expected = { - left: po.left + TestHelpers.draggable.border(p, "left") + TestHelpers.draggable.margin(el, "left"), - top: po.top + TestHelpers.draggable.border(p, "top") + TestHelpers.draggable.margin(el, "top") + left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ), + top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" ) }; - el.simulate( "drag", { + element.simulate( "drag", { dx: -100, dy: -100 }); - offsetAfter = el.offset(); - deepEqual(offsetAfter, expected, "compare offset to parent"); + offsetAfter = element.offset(); + deepEqual( offsetAfter, expected, "compare offset to parent" ); }); -test("{ containment: 'parent' }, absolute", function() { +test( "{ containment: Selector }", function() { expect( 1 ); var offsetAfter, - el = $("#draggable2").draggable({ containment: "parent" }), - p = el.parent(), + element = $( "#draggable1" ).draggable({ containment: $( "#qunit-fixture" ) }), + p = element.parent(), po = p.offset(), expected = { - left: po.left + TestHelpers.draggable.border(p, "left") + TestHelpers.draggable.margin(el, "left"), - top: po.top + TestHelpers.draggable.border(p, "top") + TestHelpers.draggable.margin(el, "top") + left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ), + top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" ) }; - el.simulate( "drag", { + element.simulate( "drag", { dx: -100, dy: -100 }); - offsetAfter = el.offset(); - deepEqual(offsetAfter, expected, "compare offset to parent"); + offsetAfter = element.offset(); + deepEqual( offsetAfter, expected, "compare offset to parent" ); }); -test("containment, default, switching after initialization", function() { +test( "{ containment: [x1, y1, x2, y2] }", function() { + expect( 1 ); + + var element = $( "#draggable1" ).draggable(), + eo = element.offset(); + + element.draggable( "option", "containment", [ eo.left, eo.top, eo.left + element.width() + 5, eo.left + element.width() + 5 ] ); + + TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0 ); +}); + +test( "{ containment: 'parent' }, relative", function() { + expect( 1 ); + + var offsetAfter, + element = $( "#draggable1" ).draggable({ containment: "parent" }), + p = element.parent(), + po = p.offset(), + expected = { + left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ), + top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" ) + }; + + element.simulate( "drag", { + dx: -100, + dy: -100 + }); + offsetAfter = element.offset(); + deepEqual( offsetAfter, expected, "compare offset to parent" ); +}); + +test( "{ containment: 'parent' }, absolute", function() { + expect( 1 ); + + var offsetAfter, + element = $( "#draggable2" ).draggable({ containment: "parent" }), + p = element.parent(), + po = p.offset(), + expected = { + left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ), + top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" ) + }; + + element.simulate( "drag", { + dx: -100, + dy: -100 + }); + offsetAfter = element.offset(); + deepEqual( offsetAfter, expected, "compare offset to parent" ); +}); + +test( "containment, default, switching after initialization", function() { expect( 2 ); - var el = $("#draggable1").draggable({ containment: false }); + var element = $( "#draggable1" ).draggable({ containment: false }); - TestHelpers.draggable.testDrag(el, el, -100, -100, -100, -100); + TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100 ); - el.draggable( "option", "containment", "parent" ) - .css({top:0,left:0}) - .appendTo( $("#main") ); + element.draggable( "option", "containment", "parent" ) + .css({ + top: 0, + left: 0 + }) + .appendTo( $( "#main" ) ); - TestHelpers.draggable.testDrag(el, el, -100, -100, 0, 0); + TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0 ); // TODO: Switching back to false does not update to false - // el.draggable( "option", "containment", false ); - // TestHelpers.draggable.testDrag(el, el, -100, -100, -100, -100); - + // element.draggable( "option", "containment", false ); + // TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100 ); }); -/* -test("{ containment: 'document' }", function() { - expect( 1 ); +test( "{ cursor: 'auto' }, default", function() { + function getCursor() { + return $( "#draggable2" ).css( "cursor" ); + } - ok(false, "missing test - untested code is broken code"); -}); + expect( 2 ); -test("{ containment: 'window' }", function() { - expect( 1 ); - - ok(false, "missing test - untested code is broken code"); -}); - -test("{ containment: Selector }", function() { - expect( 1 ); - - ok(false, "missing test - untested code is broken code"); -}); - -test("{ containment: [x1, y1, x2, y2] }", function() { - expect( 1 ); - - ok(false, "missing test - untested code is broken code"); -}); -*/ - -test("{ cursor: 'auto' }, default", function() { - function getCursor() { return $("#draggable2").css("cursor"); } - - expect(2); - - var actual, before, after, + var actual, after, expected = "auto", - el = $("#draggable2").draggable({ + element = $( "#draggable2" ).draggable({ cursor: expected, start: function() { actual = getCursor(); } - }); + }), + before = getCursor(); - before = getCursor(); - el.simulate( "drag", { + element.simulate( "drag", { dx: -1, dy: -1 }); after = getCursor(); - equal(actual, expected, "start callback: cursor '" + expected + "'"); - equal(after, before, "after drag: cursor restored"); - + equal( actual, expected, "start callback: cursor '" + expected + "'" ); + equal( after, before, "after drag: cursor restored" ); }); -test("{ cursor: 'move' }", function() { +test( "{ cursor: 'move' }", function() { + function getCursor() { + return $( "body" ).css( "cursor" ); + } - function getCursor() { return $("body").css("cursor"); } + expect( 2 ); - expect(2); - - var actual, before, after, + var actual, after, expected = "move", - el = $("#draggable2").draggable({ + element = $( "#draggable2" ).draggable({ cursor: expected, start: function() { actual = getCursor(); } - }); + }), + before = getCursor(); - before = getCursor(); - el.simulate( "drag", { + element.simulate( "drag", { dx: -1, dy: -1 }); after = getCursor(); - equal(actual, expected, "start callback: cursor '" + expected + "'"); - equal(after, before, "after drag: cursor restored"); - + equal( actual, expected, "start callback: cursor '" + expected + "'" ); + equal( after, before, "after drag: cursor restored" ); }); -test("cursor, default, switching after initialization", function() { +test( "cursor, default, switching after initialization", function() { + expect( 3 ); - expect(3); + var element = $( "#draggable1" ).draggable(); - var el = $("#draggable1").draggable(); + TestHelpers.draggable.trackMouseCss( element ); - TestHelpers.draggable.trackMouseCss( el ); + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_cursor" ), "auto" ); - TestHelpers.draggable.move( el, 1, 1 ); - equal( el.data("last_dragged_cursor"), "auto" ); - - el.draggable( "option", "cursor", "move" ); - TestHelpers.draggable.move( el, 1, 1 ); - equal( el.data("last_dragged_cursor"), "move" ); - - el.draggable( "option", "cursor", "ns-resize" ); - TestHelpers.draggable.move( el, 1, 1 ); - equal( el.data("last_dragged_cursor"), "ns-resize" ); + element.draggable( "option", "cursor", "move" ); + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_cursor" ), "move" ); + element.draggable( "option", "cursor", "ns-resize" ); + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.data( "last_dragged_cursor" ), "ns-resize" ); }); test( "cursorAt", function() { @@ -452,7 +456,7 @@ test( "cursorAt", function() { $.each( tests, function( testName, testData ) { $.each( [ "relative", "absolute" ], function( i, position ) { - var el = $( "#draggable" + ( i + 1 ) ).draggable({ + var element = $( "#draggable" + ( i + 1 ) ).draggable({ cursorAt: testData.cursorAt, drag: function( event, ui ) { if( !testData.cursorAt ) { @@ -468,7 +472,7 @@ test( "cursorAt", function() { } }); - el.simulate( "drag", { + element.simulate( "drag", { moves: 1, dx: deltaX, dy: deltaY @@ -478,7 +482,6 @@ test( "cursorAt", function() { }); test( "cursorAt, switching after initialization", function() { - expect( 24 ); var deltaX = -3, @@ -494,9 +497,9 @@ test( "cursorAt, switching after initialization", function() { $.each( tests, function( testName, testData ) { $.each( [ "relative", "absolute" ], function( i, position ) { - var el = $( "#draggable" + ( i + 1 ) ); + var element = $( "#draggable" + ( i + 1 ) ); - el.draggable({ + element.draggable({ drag: function( event, ui ) { if( !testData.cursorAt ) { equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" ); @@ -511,558 +514,770 @@ test( "cursorAt, switching after initialization", function() { } }); - el.draggable( "option", "cursorAt", false ); - el.draggable( "option", "cursorAt", testData.cursorAt ); + element.draggable( "option", "cursorAt", false ); + element.draggable( "option", "cursorAt", testData.cursorAt ); - el.simulate( "drag", { + element.simulate( "drag", { moves: 1, dx: deltaX, dy: deltaY }); }); }); - }); - test( "disabled", function() { - expect( 3 ); - var el = $("#draggable1").draggable(); - - TestHelpers.draggable.shouldMove(el); - - el.draggable( "option", "disabled", true ); - TestHelpers.draggable.shouldNotMove(el); - - el.draggable( "option", "disabled", false ); - TestHelpers.draggable.shouldMove(el); - + var element = $( "#draggable1" ).draggable(); + + TestHelpers.draggable.shouldMove( element ); + + element.draggable( "option", "disabled", true ); + TestHelpers.draggable.shouldNotMove( element ); + + element.draggable( "option", "disabled", false ); + TestHelpers.draggable.shouldMove( element ); }); -test("{ grid: [50, 50] }, relative", function() { +test( "{ grid: [50, 50] }, relative", function() { expect( 2 ); - var el = $("#draggable1").draggable({ grid: [50, 50] }); - TestHelpers.draggable.testDrag(el, el, 24, 24, 0, 0); - TestHelpers.draggable.testDrag(el, el, 26, 25, 50, 50); + var element = $( "#draggable1" ).draggable({ grid: [ 50, 50 ] }); + TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0 ); + TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50 ); }); -test("{ grid: [50, 50] }, absolute", function() { +test( "{ grid: [50, 50] }, absolute", function() { expect( 2 ); - var el = $("#draggable2").draggable({ grid: [50, 50] }); - TestHelpers.draggable.testDrag(el, el, 24, 24, 0, 0); - TestHelpers.draggable.testDrag(el, el, 26, 25, 50, 50); + var element = $( "#draggable2" ).draggable({ grid: [ 50, 50 ] }); + TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0 ); + TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50 ); }); -test("grid, switching after initialization", function() { - +test( "grid, switching after initialization", function() { expect( 4 ); - var el = $("#draggable1").draggable(); + var element = $( "#draggable1" ).draggable(); + // Forward - TestHelpers.draggable.testDrag(el, el, 24, 24, 24, 24); - TestHelpers.draggable.testDrag(el, el, 0, 0, 0, 0); + TestHelpers.draggable.testDrag( element, element, 24, 24, 24, 24 ); + TestHelpers.draggable.testDrag( element, element, 0, 0, 0, 0 ); - el.draggable( "option", "grid", [50,50] ); - - TestHelpers.draggable.testDrag(el, el, 24, 24, 0, 0); - TestHelpers.draggable.testDrag(el, el, 26, 25, 50, 50); + element.draggable( "option", "grid", [ 50,50 ] ); + TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0 ); + TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50 ); }); -test("{ handle: 'span' }", function() { +test( "{ handle: 'span' }", function() { expect( 2 ); - var el = $("#draggable2").draggable({ handle: "span" }); + var element = $( "#draggable2" ).draggable({ handle: "span" }); - TestHelpers.draggable.testDrag(el, "#draggable2 span", 50, 50, 50, 50, "drag span"); - TestHelpers.draggable.shouldNotMove(el, "drag element"); + TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 50, 50, "drag span" ); + TestHelpers.draggable.shouldNotMove( element, "drag element" ); }); -test("{ handle: Selectors }, matching parent selector", function() { +/* +test( "{ handle: Selectors }, matching parent selector", function() { expect( 4 ); - var el = $("#draggable2").draggable({ handle: "span a" }); - - $("#qunit-fixture").append( "
    " ); - - el.find( "span" ).append( "" ); - - $("#wrapping a").append( el ); - - TestHelpers.draggable.testDrag(el, "#draggable2 span a", 50, 50, 50, 50, "drag span child"); - TestHelpers.draggable.shouldNotMove( $("#wrapping a") ); - - $("#draggable2").draggable( "option", "handle", "span > a" ); - $("#draggable2").find( "a" ).append( "" ); - - - TestHelpers.draggable.testDrag(el, $("#draggable2 span a").first(), 50, 50, 50, 50, "drag span child"); - TestHelpers.draggable.shouldNotMove( $("#draggable2 span a").last() ); - -}); + var element = $( "#draggable2" ).draggable({ handle: "span a" }); -test("handle, default, switching after initialization", function() { + $( "#qunit-fixture" ).append( "" ); + + element.find( "span" ).append( "" ); + + $( "#wrapping a" ).append( element ); + + TestHelpers.draggable.testDrag( element, "#draggable2 span a", 50, 50, 50, 50, "drag span child" ); + TestHelpers.draggable.shouldNotMove( $( "#wrapping a" ) ); + + $( "#draggable2" ).draggable( "option", "handle", "span > a" ); + $( "#draggable2" ).find( "a" ).append( "" ); + + TestHelpers.draggable.testDrag( element, $( "#draggable2 span a" ).first(), 50, 50, 50, 50, "drag span child" ); + TestHelpers.draggable.shouldNotMove( $( "#draggable2 span a" ).last() ); + +}); +*/ + +test( "handle, default, switching after initialization", function() { expect( 6 ); - var el = $("#draggable2").draggable(); + var element = $( "#draggable2" ).draggable(); - TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50); - TestHelpers.draggable.testDrag(el, "#draggable2 span", 100, 100, 100, 100); + TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 50 ); + TestHelpers.draggable.testDrag( element, "#draggable2 span", 100, 100, 100, 100 ); // Switch - el.draggable( "option", "handle", "span" ); - TestHelpers.draggable.testDrag(el, el, 50, 50, 0, 0); - TestHelpers.draggable.testDrag(el, "#draggable2 span", 100, 100, 100, 100); + element.draggable( "option", "handle", "span" ); + TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 0 ); + TestHelpers.draggable.testDrag( element, "#draggable2 span", 100, 100, 100, 100 ); // And back - el.draggable( "option", "handle", false ); - TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50); - TestHelpers.draggable.testDrag(el, "#draggable2 span", 100, 100, 100, 100); - + element.draggable( "option", "handle", false ); + TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 50 ); + TestHelpers.draggable.testDrag( element, "#draggable2 span", 100, 100, 100, 100 ); }); -test("helper, default, switching after initialization", function() { +test( "helper, default, switching after initialization", function() { expect( 3 ); - var el = $("#draggable1").draggable(); - TestHelpers.draggable.shouldMove(el); + var element = $( "#draggable1" ).draggable(); + TestHelpers.draggable.shouldMove( element ); - el.draggable( "option", "helper", "clone" ); - TestHelpers.draggable.shouldNotMove(el); - - el.draggable( "option", "helper", "original" ); - TestHelpers.draggable.shouldMove(el); + element.draggable( "option", "helper", "clone" ); + TestHelpers.draggable.shouldNotMove( element ); + element.draggable( "option", "helper", "original" ); + TestHelpers.draggable.shouldMove( element ); }); -test("{ helper: 'clone' }, relative", function() { +test( "{ helper: 'clone' }, relative", function() { expect( 1 ); - var el = $("#draggable1").draggable({ helper: "clone" }); - TestHelpers.draggable.shouldNotMove(el); + var element = $( "#draggable1" ).draggable({ helper: "clone" }); + TestHelpers.draggable.shouldNotMove( element ); }); -test("{ helper: 'clone' }, absolute", function() { +test( "{ helper: 'clone' }, absolute", function() { expect( 1 ); - var el = $("#draggable2").draggable({ helper: "clone" }); - TestHelpers.draggable.shouldNotMove(el); + var element = $( "#draggable2" ).draggable({ helper: "clone" }); + TestHelpers.draggable.shouldNotMove( element ); }); -test("{ helper: 'original' }, relative, with scroll offset on parent", function() { +test( "{ helper: 'original' }, relative, with scroll offset on parent", function() { expect( 3 ); - var el = $("#draggable1").draggable({ helper: "original" }); + var element = $( "#draggable1" ).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.testScroll( element, "relative" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.testScroll( element, "static" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "absolute"); + TestHelpers.draggable.testScroll( element, "absolute" ); TestHelpers.draggable.restoreScroll(); - }); -test("{ helper: 'original' }, relative, with scroll offset on root", function() { +test( "{ helper: 'original' }, relative, with scroll offset on root", function() { expect( 3 ); - var el = $("#draggable1").draggable({ helper: "original" }); + var element = $( "#draggable1" ).draggable({ helper: "original" }); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "relative" ); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "static" ); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "absolute"); - - TestHelpers.draggable.restoreScroll("root"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "absolute" ); + TestHelpers.draggable.restoreScroll( "root" ); }); -test("{ helper: 'original' }, relative, with scroll offset on root and parent", function() { +test( "{ helper: 'original' }, relative, with scroll offset on root and parent", function() { + expect( 3 ); - expect(3); - - var el = $("#draggable1").draggable({ helper: "original" }); + var element = $( "#draggable1" ).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "relative" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "static" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "absolute"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "absolute" ); TestHelpers.draggable.restoreScroll(); - TestHelpers.draggable.restoreScroll("root"); - + TestHelpers.draggable.restoreScroll( "root" ); }); -test("{ helper: 'original' }, absolute, with scroll offset on parent", function() { +test( "{ helper: 'original' }, absolute, with scroll offset on parent", function() { + expect( 3 ); - expect(3); - - var el = $("#draggable1").css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" }); + var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.testScroll( element, "relative" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.testScroll( element, "static" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "absolute"); + TestHelpers.draggable.testScroll( element, "absolute" ); TestHelpers.draggable.restoreScroll(); - }); -test("{ helper: 'original' }, absolute, with scroll offset on root", function() { +test( "{ helper: 'original' }, absolute, with scroll offset on root", function() { + expect( 3 ); - expect(3); + var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" }); - var el = $("#draggable1").css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" }); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "relative" ); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "static" ); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "static"); - - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "absolute"); - - TestHelpers.draggable.restoreScroll("root"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "absolute" ); + TestHelpers.draggable.restoreScroll( "root" ); }); -test("{ helper: 'original' }, absolute, with scroll offset on root and parent", function() { +test( "{ helper: 'original' }, absolute, with scroll offset on root and parent", function() { + expect( 3 ); - expect(3); - - var el = $("#draggable1").css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" }); + var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "relative" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "static" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "absolute"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "absolute" ); TestHelpers.draggable.restoreScroll(); - TestHelpers.draggable.restoreScroll("root"); - + TestHelpers.draggable.restoreScroll( "root" ); }); -test("{ helper: 'original' }, fixed, with scroll offset on parent", function() { +test( "{ helper: 'original' }, fixed, with scroll offset on parent", function() { + expect( 3 ); - expect(3); - - var el = $("#draggable1").css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" }); + var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.testScroll( element, "relative" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.testScroll( element, "static" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.testScroll(el, "absolute"); + TestHelpers.draggable.testScroll( element, "absolute" ); TestHelpers.draggable.restoreScroll(); - }); -test("{ helper: 'original' }, fixed, with scroll offset on root", function() { +test( "{ helper: 'original' }, fixed, with scroll offset on root", function() { + expect( 3 ); - expect(3); + var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" }); - var el = $("#draggable1").css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" }); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "relative" ); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "static" ); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "absolute" ); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "absolute"); - - TestHelpers.draggable.restoreScroll("root"); + TestHelpers.draggable.restoreScroll( "root" ); }); -test("{ helper: 'original' }, fixed, with scroll offset on root and parent", function() { +test( "{ helper: 'original' }, fixed, with scroll offset on root and parent", function() { + expect( 3 ); - expect(3); - - var el = $("#draggable1").css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" }); + var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" }); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "relative"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "relative" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "static"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "static" ); TestHelpers.draggable.setScroll(); - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.testScroll(el, "absolute"); + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.testScroll( element, "absolute" ); TestHelpers.draggable.restoreScroll(); - TestHelpers.draggable.restoreScroll("root"); - + TestHelpers.draggable.restoreScroll( "root" ); }); -test("{ helper: 'clone' }, absolute", function() { - - expect(1); +test( "{ helper: 'clone' }, absolute", function() { + expect( 1 ); var helperOffset = null, - origOffset = $("#draggable1").offset(), - el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) { + origOffset = $( "#draggable1" ).offset(), + element = $( "#draggable1" ).draggable({ helper: "clone", drag: function( event, ui) { helperOffset = ui.helper.offset(); } }); - el.simulate( "drag", { + element.simulate( "drag", { dx: 1, dy: 1 }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - + deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" ); }); -test("{ helper: 'clone' }, absolute with scroll offset on parent", function() { - - expect(3); +test( "{ helper: 'clone' }, absolute with scroll offset on parent", function() { + expect( 3 ); TestHelpers.draggable.setScroll(); var helperOffset = null, origOffset = null, - el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) { - helperOffset = ui.helper.offset(); - } }); - - $("#main").css("position", "relative"); - origOffset = $("#draggable1").offset(); - el.simulate( "drag", { - dx: 1, - dy: 1 - }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - - $("#main").css("position", "static"); - origOffset = $("#draggable1").offset(); - el.simulate( "drag", { - dx: 1, - dy: 1 - }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - - $("#main").css("position", "absolute"); - origOffset = $("#draggable1").offset(); - el.simulate( "drag", { - dx: 1, - dy: 1 - }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - - TestHelpers.draggable.restoreScroll(); - -}); - -test("{ helper: 'clone' }, absolute with scroll offset on root", function() { - - expect(3); - - TestHelpers.draggable.setScroll("root"); - var helperOffset = null, - origOffset = null, - el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) { - helperOffset = ui.helper.offset(); - } }); - - $("#main").css("position", "relative"); - origOffset = $("#draggable1").offset(); - el.simulate( "drag", { - dx: 1, - dy: 1 - }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - - $("#main").css("position", "static"); - origOffset = $("#draggable1").offset(); - el.simulate( "drag", { - dx: 1, - dy: 1 - }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - - $("#main").css("position", "absolute"); - origOffset = $("#draggable1").offset(); - el.simulate( "drag", { - dx: 1, - dy: 1 - }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - - TestHelpers.draggable.restoreScroll("root"); - -}); - -test("{ helper: 'clone' }, absolute with scroll offset on root and parent", function() { - - expect(3); - - TestHelpers.draggable.setScroll("root"); - TestHelpers.draggable.setScroll(); - - var helperOffset = null, - origOffset = null, - el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) { - helperOffset = ui.helper.offset(); - } }); - - $("#main").css("position", "relative"); - origOffset = $("#draggable1").offset(); - el.simulate( "drag", { - dx: 1, - dy: 1 - }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - - $("#main").css("position", "static"); - origOffset = $("#draggable1").offset(); - el.simulate( "drag", { - dx: 1, - dy: 1 - }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - - $("#main").css("position", "absolute"); - origOffset = $("#draggable1").offset(); - el.simulate( "drag", { - dx: 1, - dy: 1 - }); - deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] "); - - TestHelpers.draggable.restoreScroll("root"); - TestHelpers.draggable.restoreScroll(); - -}); - -test("{ opacity: 0.5 }", function() { - - expect(1); - - var opacity = null, - el = $("#draggable2").draggable({ - opacity: 0.5, - start: function() { - opacity = $(this).css("opacity"); + element = $( "#draggable1" ).draggable({ + helper: "clone", + drag: function( event, ui) { + helperOffset = ui.helper.offset(); } }); - el.simulate( "drag", { + $( "#main" ).css( "position", "relative" ); + origOffset = $( "#draggable1" ).offset(); + element.simulate( "drag", { + dx: 1, + dy: 1 + }); + deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" ); + + $( "#main" ).css( "position", "static" ); + origOffset = $( "#draggable1" ).offset(); + element.simulate( "drag", { + dx: 1, + dy: 1 + }); + deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" ); + + $( "#main" ).css( "position", "absolute" ); + origOffset = $( "#draggable1" ).offset(); + element.simulate( "drag", { + dx: 1, + dy: 1 + }); + deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" ); + + TestHelpers.draggable.restoreScroll(); +}); + +test( "{ helper: 'clone' }, absolute with scroll offset on root", function() { + expect( 3 ); + + TestHelpers.draggable.setScroll( "root" ); + var helperOffset = null, + origOffset = null, + element = $( "#draggable1" ).draggable({ + helper: "clone", + drag: function( event, ui) { + helperOffset = ui.helper.offset(); + } + }); + + $( "#main" ).css( "position", "relative" ); + origOffset = $( "#draggable1" ).offset(); + element.simulate( "drag", { + dx: 1, + dy: 1 + }); + deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" ); + + $( "#main" ).css( "position", "static" ); + origOffset = $( "#draggable1" ).offset(); + element.simulate( "drag", { + dx: 1, + dy: 1 + }); + deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" ); + + $( "#main" ).css( "position", "absolute" ); + origOffset = $( "#draggable1" ).offset(); + element.simulate( "drag", { + dx: 1, + dy: 1 + }); + deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" ); + + TestHelpers.draggable.restoreScroll( "root" ); +}); + +test( "{ helper: 'clone' }, absolute with scroll offset on root and parent", function() { + expect( 3 ); + + TestHelpers.draggable.setScroll( "root" ); + TestHelpers.draggable.setScroll(); + + var helperOffset = null, + origOffset = null, + element = $( "#draggable1" ).draggable({ + helper: "clone", + drag: function( event, ui) { + helperOffset = ui.helper.offset(); + } + }); + + $( "#main" ).css( "position", "relative" ); + origOffset = $( "#draggable1" ).offset(); + element.simulate( "drag", { + dx: 1, + dy: 1 + }); + deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" ); + + $( "#main" ).css( "position", "static" ); + origOffset = $( "#draggable1" ).offset(); + element.simulate( "drag", { + dx: 1, + dy: 1 + }); + deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" ); + + $( "#main" ).css( "position", "absolute" ); + origOffset = $( "#draggable1" ).offset(); + element.simulate( "drag", { + dx: 1, + dy: 1 + }); + deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" ); + + TestHelpers.draggable.restoreScroll( "root" ); + TestHelpers.draggable.restoreScroll(); +}); + +test( "{ opacity: 0.5 }", function() { + expect( 1 ); + + var opacity = null, + element = $( "#draggable2" ).draggable({ + opacity: 0.5, + start: function() { + opacity = $(this).css( "opacity" ); + } + }); + + element.simulate( "drag", { dx: -1, dy: -1 }); - equal(opacity, 0.5, "start callback: opacity is"); - + equal( opacity, 0.5, "start callback: opacity is" ); }); -test("opacity, default, switching after initialization", function() { - - expect(3); +test( "opacity, default, switching after initialization", function() { + expect( 3 ); var opacity = null, - el = $("#draggable2").draggable({ + element = $( "#draggable2" ).draggable({ start: function() { - opacity = $(this).css("opacity"); + opacity = $(this).css( "opacity" ); } }); - TestHelpers.draggable.move( el, 1, 1 ); - equal( opacity, 1 ); - - el.draggable( "option", "opacity", 0.5 ); - TestHelpers.draggable.move( el, 2, 1 ); - equal( opacity, 0.5 ); - - el.draggable( "option", "opacity", false ); - TestHelpers.draggable.move( el, 3, 1 ); + TestHelpers.draggable.move( element, 1, 1 ); equal( opacity, 1 ); + element.draggable( "option", "opacity", 0.5 ); + TestHelpers.draggable.move( element, 2, 1 ); + equal( opacity, 0.5 ); + + element.draggable( "option", "opacity", false ); + TestHelpers.draggable.move( element, 3, 1 ); + equal( opacity, 1 ); }); -test("{ zIndex: 10 }", function() { +asyncTest( "revert and revertDuration", function() { + expect( 4 ); - expect(1); + var element = $( "#draggable2" ).draggable({ + revert: true, + revertDuration: 0 + }); + TestHelpers.draggable.shouldNotMove( element, "revert: true, revertDuration: 0 should revert immediately" ); + + $( "#draggable2" ).draggable( "option", "revert", "invalid" ); + TestHelpers.draggable.shouldNotMove( element, "revert: invalid, revertDuration: 0 should revert immediately" ); + + $( "#draggable2" ).draggable( "option", "revert", false ); + TestHelpers.draggable.shouldMove( element, "revert: false should allow movement" ); + + $( "#draggable2" ).draggable( "option", { + revert: true, + revertDuration: 200, + stop: function() { + start(); + } + }); + + // animation are async, so test for it asynchronously + TestHelpers.draggable.move( element, 50, 50 ); + setTimeout( function() { + ok( $( "#draggable2" ).is( ":animated" ), "revert: true with revertDuration should animate" ); + }); +}); + +test( "revert: valid", function() { + expect( 1 ); + + var element = $( "#draggable2" ).draggable({ + revert: "valid", + revertDuration: 0 + }); + + $( "#droppable" ).droppable(); + + TestHelpers.draggable.testDrag( element, element, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable" ); +}); + +test( "scope", function() { + expect( 2 ); + + var element = $( "#draggable2" ).draggable({ + scope: "tasks", + revert: "valid", + revertDuration: 0 + }); + + $( "#droppable" ).droppable({ scope: "tasks" }); + + TestHelpers.draggable.testDrag( element, element, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable" ); + + $( "#droppable" ).droppable( "destroy" ).droppable({ scope: "nottasks" }); + + TestHelpers.draggable.testDrag( element, element, 100, 100, 100, 100, "revert: valid reverts when dropped on a droppable" ); +}); + +test( "scroll, scrollSensitivity, and scrollSpeed", function() { + expect( 2 ); + + var viewportHeight = $( window ).height(), + element = $( "#draggable1" ).draggable({ scroll: true }), + scrollSensitivity = element.draggable( "option", "scrollSensitivity" ), + scrollSpeed = element.draggable( "option", "scrollSpeed" ); + + element.offset({ + top: viewportHeight - scrollSensitivity - 1, + left: 1 + }); + + element.simulate( "drag", { + dx: 1, + y: viewportHeight - scrollSensitivity - 1, + moves: 1 + }); + + ok( $( window ).scrollTop() === 0, "scroll: true doesn't scroll when the element is dragged outside of scrollSensitivity" ); + + element.draggable( "option", "scrollSensitivity", scrollSensitivity + 10 ); + + element.offset({ + top: viewportHeight - scrollSensitivity - 1, + left: 1 + }); + + element.simulate( "drag", { + dx: 1, + y: viewportHeight - scrollSensitivity - 1, + moves: 1 + }); + + ok( $( window ).scrollTop() === scrollSpeed, "scroll: true scrolls when the element is dragged within scrollSensitivity" ); + + TestHelpers.draggable.restoreScroll( document ); +}); + +test( "snap, snapMode, and snapTolerance", function() { + expect( 9 ); + + var newX, newY, + snapTolerance = 15, + element = $( "#draggable1" ).draggable({ + snap: true, + snapMode: "both", + snapTolerance: snapTolerance + }), + element2 = $( "#draggable2" ).draggable(); + + element.offset({ + top: 1, + left: 1 + }); + + newX = element2.offset().left - element.outerWidth() - snapTolerance - 2; + newY = element2.offset().top; + + element.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap outside the snapTolerance" ); + + newX += 3; + + element.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + notDeepEqual( element.offset(), { top: newY, left: newX }, "snaps inside the snapTolerance" ); + + element.draggable( "option", "snap", "#draggable2" ); + + element.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + notDeepEqual( element.offset(), { top: newY, left: newX }, "snaps based on selector" ); + + element.draggable( "option", "snap", "#draggable3" ); + + element.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap based on invalid selector" ); + + element.draggable( "option", "snap", true ); + element.draggable( "option", "snapTolerance", snapTolerance - 2 ); + element.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap outside the modified snapTolerance" ); + + element.draggable( "option", "snapTolerance", snapTolerance ); + element.draggable( "option", "snapMode", "inner" ); + + element.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap inside the outer snapTolerance area when snapMode is inner" ); + + newX = element2.offset().left - snapTolerance - 1; + newY = element2.offset().top; + + element.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap inside the outer snapTolerance area when snapMode is inner" ); + + newX++; + + element.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + notDeepEqual( element.offset(), { top: newY, left: newX }, "snaps inside the inner snapTolerance area when snapMode is inner" ); + + element.draggable( "option", "snapMode", "outer" ); + + element.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap on the inner snapTolerance area when snapMode is outer" ); +}); + +test( "stack", function() { + expect( 2 ); + + var element = $( "#draggable1" ).draggable({ + stack: "#draggable1, #draggable2" + }), + element2 = $( "#draggable2" ).draggable({ + stack: "#draggable1, #draggable2" + }); + + TestHelpers.draggable.move( element, 1, 1 ); + equal( element.css( "zIndex" ), "2", "stack increments zIndex correctly" ); + + TestHelpers.draggable.move( element2, 1, 1 ); + equal( element2.css( "zIndex" ), "3", "stack increments zIndex correctly" ); +}); + +test( "{ zIndex: 10 }", function() { + expect( 1 ); var actual, expected = 10, - el = $("#draggable2").draggable({ + element = $( "#draggable2" ).draggable({ zIndex: expected, start: function() { - actual = $(this).css("zIndex"); + actual = $(this).css( "zIndex" ); } }); - el.simulate( "drag", { + element.simulate( "drag", { dx: -1, dy: -1 }); - equal(actual, expected, "start callback: zIndex is"); + equal( actual, expected, "start callback: zIndex is" ); }); -test("zIndex, default, switching after initialization", function() { +test( "zIndex, default, switching after initialization", function() { - expect(3); + expect( 3 ); var zindex = null, - el = $("#draggable2").draggable({ + element = $( "#draggable2" ).draggable({ start: function() { - zindex = $(this).css("z-index"); + zindex = $(this).css( "z-index" ); } }); - - el.css( "z-index", 1 ); - TestHelpers.draggable.move( el, 1, 1 ); + element.css( "z-index", 1 ); + + TestHelpers.draggable.move( element, 1, 1 ); equal( zindex, 1 ); - - el.draggable( "option", "zIndex", 5 ); - TestHelpers.draggable.move( el, 2, 1 ); + + element.draggable( "option", "zIndex", 5 ); + TestHelpers.draggable.move( element, 2, 1 ); equal( zindex, 5 ); - - el.draggable( "option", "zIndex", false ); - TestHelpers.draggable.move( el, 3, 1 ); + + element.draggable( "option", "zIndex", false ); + TestHelpers.draggable.move( element, 3, 1 ); equal( zindex, 1 ); }); -})(jQuery); +})( jQuery ); diff --git a/tests/unit/draggable/draggable_test_helpers.js b/tests/unit/draggable/draggable_test_helpers.js index de76084b8..250288a5b 100644 --- a/tests/unit/draggable/draggable_test_helpers.js +++ b/tests/unit/draggable/draggable_test_helpers.js @@ -50,12 +50,10 @@ TestHelpers.draggable = { return parseInt(el.css("margin-" + side), 10) || 0; }, move: function( el, x, y ) { - $( el ).simulate( "drag", { dx: x, dy: y }); - }, trackMouseCss : function( el ) { el.on( "drag", function() { @@ -63,7 +61,6 @@ TestHelpers.draggable = { }); }, trackAppendedParent : function( el ) { - // appendTo ignored without being clone el.draggable( "option", "helper", "clone" ); @@ -71,6 +68,5 @@ TestHelpers.draggable = { // Get what parent is at time of drag el.data( "last_dragged_parent", ui.helper.parent()[0] ); }); - } }; \ No newline at end of file diff --git a/tests/unit/droppable/all.html b/tests/unit/droppable/all.html index 22ba18e0f..890e88a83 100644 --- a/tests/unit/droppable/all.html +++ b/tests/unit/droppable/all.html @@ -4,7 +4,7 @@ jQuery UI Droppable Test Suite - + diff --git a/tests/unit/droppable/droppable.html b/tests/unit/droppable/droppable.html index 0838795dd..7d90116d6 100644 --- a/tests/unit/droppable/droppable.html +++ b/tests/unit/droppable/droppable.html @@ -41,6 +41,7 @@
    Droppable
    Draggable
    +
    Droppable
     
    diff --git a/tests/unit/droppable/droppable_events.js b/tests/unit/droppable/droppable_events.js index 8f842e942..4b8fe5acd 100644 --- a/tests/unit/droppable/droppable_events.js +++ b/tests/unit/droppable/droppable_events.js @@ -1,13 +1,41 @@ -/* - * droppable_events.js - */ -(function($) { +(function( $ ) { + +module( "droppable: events" ); + +test( "droppable destruction/recreation on drop event", function() { + expect( 1 ); + + var config = { + activeClass: "active", + drop: function() { + var element = $( this ), + newDroppable = $( "
    " ) + .css({ width: 100, height: 100 }) + .text( "Droppable" ); + element.after( newDroppable ); + element.remove(); + newDroppable.droppable( config ); + } + }, + + draggable = $( "#draggable1" ).draggable(), + droppable1 = $( "#droppable1" ).droppable( config ), + droppable2 = $( "#droppable2" ).droppable( config ), + + droppableOffset = droppable1.offset(), + draggableOffset = draggable.offset(), + dx = droppableOffset.left - draggableOffset.left, + dy = droppableOffset.top - draggableOffset.top; + + draggable.simulate( "drag", { + dx: dx, + dy: dy + }); + + ok( !droppable2.hasClass( "active" ), "subsequent droppable no longer active" ); +}); -module("droppable: events"); -// this is here to make JSHint pass "unused", and we don't want to -// remove the parameter for when we finally implement -$.noop(); // todo: comment the following in when ready to actually test /* @@ -32,4 +60,4 @@ test("drop", function() { }); */ -})(jQuery); +})( jQuery ); diff --git a/tests/unit/effects/all.html b/tests/unit/effects/all.html index 1773756ad..36d74ce9c 100644 --- a/tests/unit/effects/all.html +++ b/tests/unit/effects/all.html @@ -4,7 +4,7 @@ jQuery UI Effects Test Suite - + diff --git a/tests/unit/effects/effects.html b/tests/unit/effects/effects.html index c283eabff..4538ecb03 100644 --- a/tests/unit/effects/effects.html +++ b/tests/unit/effects/effects.html @@ -96,7 +96,11 @@

      - +
      +
      +

      Child Element Test

      diff --git a/tests/unit/effects/effects_core.js b/tests/unit/effects/effects_core.js index 26390b7d3..11e9d0b45 100644 --- a/tests/unit/effects/effects_core.js +++ b/tests/unit/effects/effects_core.js @@ -16,6 +16,24 @@ var minDuration = 15, module( "effects.core" ); +// TODO: test all signatures of .show(), .hide(), .toggle(). +// Look at core's signatures and UI's signatures. +asyncTest( ".hide() with step", function() { + expect( 1 ); + var element = $( "#elem" ), + step = function() { + ok( true, "step callback invoked" ); + step = $.noop; + }; + + element.hide({ + step: function() { + step(); + }, + complete: start + }); +}); + test( "Immediate Return Conditions", function() { var hidden = $( "div.hidden" ), count = 0; @@ -28,6 +46,14 @@ test( "Immediate Return Conditions", function() { equal( ++count, 3, "Both Functions worked properly" ); }); +test( ".hide() with hidden parent", function() { + expect( 1 ); + var element = $( "div.hidden" ).children(); + element.hide( "blind", function() { + equal( element.css( "display" ), "none", "display: none" ); + }); +}); + asyncTest( "Parse of null for options", function() { var hidden = $( "div.hidden" ), count = 0; @@ -38,6 +64,17 @@ asyncTest( "Parse of null for options", function() { }); }); +test( "removeClass", function() { + expect( 3 ); + + var element = $( "
      " ); + equal( "", element[ 0 ].className ); + element.addClass( "destroyed" ); + equal( "destroyed", element[ 0 ].className ); + element.removeClass(); + equal( "", element[ 0 ].className ); +}); + /* TODO: Disabled - Can't figure out why this is failing in IE 6/7 test( "createWrapper and removeWrapper retain focused elements (#7595)", function() { diff --git a/tests/unit/index.html b/tests/unit/index.html index 8075ce2a4..6244fe1b6 100644 --- a/tests/unit/index.html +++ b/tests/unit/index.html @@ -7,7 +7,7 @@ - + diff --git a/tests/unit/menu/all.html b/tests/unit/menu/all.html index b05d82146..b34fa5e64 100644 --- a/tests/unit/menu/all.html +++ b/tests/unit/menu/all.html @@ -4,7 +4,7 @@ jQuery UI Menu Test Suite - + diff --git a/tests/unit/position/all.html b/tests/unit/position/all.html index 4019fd7c5..7dfcaac81 100644 --- a/tests/unit/position/all.html +++ b/tests/unit/position/all.html @@ -4,7 +4,7 @@ jQuery UI Position Test Suite - + diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index 7b51223ac..cefd7929c 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -221,7 +221,7 @@ test( "of", function() { }); test( "offsets", function() { - expect( 4 ); + expect( 7 ); $( "#elx" ).position({ my: "left top", @@ -254,6 +254,30 @@ test( "offsets", function() { collision: "none" }); deepEqual( $( "#elx" ).offset(), { top: 65, left: 37 }, "percentage offsets in my" ); + + $( "#elx" ).position({ + my: "left-30.001% top+50.0%", + at: "left bottom", + of: "#parentx", + collision: "none" + }); + deepEqual( $( "#elx" ).offset(), { top: 65, left: 37 }, "decimal percentage offsets in my" ); + + $( "#elx" ).position({ + my: "left+10.4 top-10.6", + at: "left bottom", + of: "#parentx", + collision: "none" + }); + deepEqual( $( "#elx" ).offset(), { top: 49, left: 50 }, "decimal offsets in my" ); + + $( "#elx" ).position({ + my: "left+right top-left", + at: "left-top bottom-bottom", + of: "#parentx", + collision: "none" + }); + deepEqual( $( "#elx" ).offset(), { top: 60, left: 40 }, "invalid offsets" ); }); test( "using", function() { diff --git a/tests/unit/progressbar/all.html b/tests/unit/progressbar/all.html index 7f92267a5..18ec34c86 100644 --- a/tests/unit/progressbar/all.html +++ b/tests/unit/progressbar/all.html @@ -4,7 +4,7 @@ jQuery UI Progressbar Test Suite - + diff --git a/tests/unit/qunit-composite.css b/tests/unit/qunit-composite.css index df47362db..c530436da 100644 --- a/tests/unit/qunit-composite.css +++ b/tests/unit/qunit-composite.css @@ -1,13 +1,13 @@ -iframe.qunit-subsuite{ - position: fixed; - bottom: 0; - left: 0; - - margin: 0; - padding: 0; - border-width: 1px 0 0; - height: 45%; - width: 100%; +iframe.qunit-subsuite { + position: fixed; + bottom: 0; + left: 0; - background: #fff; -} \ No newline at end of file + margin: 0; + padding: 0; + border-width: 1px 0 0; + height: 45%; + width: 100%; + + background: #fff; +} diff --git a/tests/unit/qunit-composite.js b/tests/unit/qunit-composite.js index b3df04217..2e5454056 100644 --- a/tests/unit/qunit-composite.js +++ b/tests/unit/qunit-composite.js @@ -16,8 +16,15 @@ QUnit.extend( QUnit, { }, runSuite: function( suite ) { + var path = suite; + + if ( QUnit.is( "object", suite ) ) { + path = suite.path; + suite = suite.name; + } + asyncTest( suite, function() { - QUnit.iframe.setAttribute( "src", suite ); + QUnit.iframe.setAttribute( "src", path ); }); }, @@ -33,6 +40,9 @@ QUnit.extend( QUnit, { var module, test, count = 0; + if (iframe.src === "") { + return; + } iframeWin.QUnit.moduleStart(function( data ) { // capture module name for messages diff --git a/tests/unit/resizable/all.html b/tests/unit/resizable/all.html index 469bf8d1d..74b723625 100644 --- a/tests/unit/resizable/all.html +++ b/tests/unit/resizable/all.html @@ -4,7 +4,7 @@ jQuery UI Resizable Test Suite - + diff --git a/tests/unit/selectable/all.html b/tests/unit/selectable/all.html index 373b9e480..e517ef33d 100644 --- a/tests/unit/selectable/all.html +++ b/tests/unit/selectable/all.html @@ -4,7 +4,7 @@ jQuery UI Selectable Test Suite - + diff --git a/tests/unit/slider/all.html b/tests/unit/slider/all.html index 1cd5e485d..039966ec3 100644 --- a/tests/unit/slider/all.html +++ b/tests/unit/slider/all.html @@ -4,7 +4,7 @@ jQuery UI Slider Test Suite - + diff --git a/tests/unit/slider/slider_core.js b/tests/unit/slider/slider_core.js index 7195147cc..19c9abb8e 100644 --- a/tests/unit/slider/slider_core.js +++ b/tests/unit/slider/slider_core.js @@ -1,300 +1,300 @@ /* * slider unit tests */ -(function($) { +(function( $ ) { // // Slider Test Helper Functions // -var el, options; +var element, options; function handle() { - return el.find(".ui-slider-handle"); + return element.find( ".ui-slider-handle" ); } // Slider Tests -module("slider: core"); +module( "slider: core" ); -test("keydown HOME on handle sets value to min", function() { +test( "keydown HOME on handle sets value to min", function() { expect( 2 ); - el = $("
      "); + element = $( "
      " ); options = { max: 5, min: -5, orientation: "horizontal", step: 1 }; - el.slider(options); + element.slider( options ); - el.slider("value", 0); + element.slider( "value", 0 ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.HOME }); - equal(el.slider("value"), options.min); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); + equal(element.slider( "value" ), options.min ); - el.slider("destroy"); + element.slider( "destroy" ); - el = $("
      "); + element = $( "
      " ); options = { max: 5, min: -5, orientation: "vertical", step: 1 }; - el.slider(options); + element.slider( options ); - el.slider("value", 0); + element.slider( "value", 0 ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.HOME }); - equal(el.slider("value"), options.min); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); + equal(element.slider( "value" ), options.min) ; - el.slider("destroy"); + element.slider( "destroy" ); }); -test("keydown END on handle sets value to max", function() { +test( "keydown END on handle sets value to max", function() { expect( 2 ); - el = $("
      "); + element = $( "
      " ); options = { max: 5, min: -5, orientation: "horizontal", step: 1 }; - el.slider(options); + element.slider( options ); - el.slider("value", 0); + element.slider( "value", 0 ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.END }); - equal(el.slider("value"), options.max); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.END } ); + equal(element.slider( "value" ), options.max) ; - el.slider("destroy"); + element.slider( "destroy" ); - el = $("
      "); + element = $( "
      " ); options = { max: 5, min: -5, orientation: "vertical", step: 1 }; - el.slider(options); + element.slider( options ); - el.slider("value", 0); + element.slider( "value", 0 ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.END }); - equal(el.slider("value"), options.max); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.END } ); + equal(element.slider( "value" ), options.max ); - el.slider("destroy"); + element.slider( "destroy" ); }); -test("keydown PAGE_UP on handle increases value by 1/5 range, not greater than max", function() { +test( "keydown PAGE_UP on handle increases value by 1/5 range, not greater than max", function() { expect( 4 ); - $.each(["horizontal", "vertical"], function(i, orientation) { - el = $("
      "); + $.each( [ "horizontal", "vertical" ], function( i, orientation ) { + element = $( "
      " ); options = { max: 100, min: 0, orientation: orientation, step: 1 }; - el.slider(options); + element.slider( options ); - el.slider("value", 70); + element.slider( "value", 70); - handle().simulate("keydown", { keyCode: $.ui.keyCode.PAGE_UP }); - equal(el.slider("value"), 90); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equal(element.slider( "value" ), 90); - handle().simulate("keydown", { keyCode: $.ui.keyCode.PAGE_UP }); - equal(el.slider("value"), 100); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equal(element.slider( "value" ), 100); - el.slider("destroy"); + element.slider( "destroy" ); }); }); -test("keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than min", function() { +test( "keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than min", function() { expect( 4 ); - $.each(["horizontal", "vertical"], function(i, orientation) { - el = $("
      "); + $.each( [ "horizontal", "vertical" ], function( i, orientation ) { + element = $( "
      " ); options = { max: 100, min: 0, orientation: orientation, step: 1 }; - el.slider(options); + element.slider( options ); - el.slider("value", 30); + element.slider( "value", 30); - handle().simulate("keydown", { keyCode: $.ui.keyCode.PAGE_DOWN }); - equal(el.slider("value"), 10); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equal(element.slider( "value" ), 10); - handle().simulate("keydown", { keyCode: $.ui.keyCode.PAGE_DOWN }); - equal(el.slider("value"), 0); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equal(element.slider( "value" ), 0 ); - el.slider("destroy"); + element.slider( "destroy" ); }); }); -test("keydown UP on handle increases value by step, not greater than max", function() { +test( "keydown UP on handle increases value by step, not greater than max", function() { expect( 4 ); - el = $("
      "); + element = $( "
      " ); options = { max: 5, min: -5, orientation: "horizontal", step: 1 }; - el.slider(options); + element.slider(options); - el.slider("value", options.max - options.step); + element.slider( "value", options.max - options.step ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.UP }); - equal(el.slider("value"), options.max); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + equal(element.slider( "value" ), options.max ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.UP }); - equal(el.slider("value"), options.max); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + equal(element.slider( "value" ), options.max ); - el.slider("destroy"); + element.slider( "destroy" ); - el = $("
      "); + element = $( "
      " ); options = { max: 5, min: -5, orientation: "vertical", step: 1 }; - el.slider(options); + element.slider( options ); - el.slider("value", options.max - options.step); + element.slider( "value", options.max - options.step ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.UP }); - equal(el.slider("value"), options.max); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + equal(element.slider( "value" ), options.max ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.UP }); - equal(el.slider("value"), options.max); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + equal(element.slider( "value" ), options.max ); - el.slider("destroy"); + element.slider( "destroy" ); }); -test("keydown RIGHT on handle increases value by step, not greater than max", function() { +test( "keydown RIGHT on handle increases value by step, not greater than max", function() { expect( 4 ); - el = $("
      "); + element = $( "
      " ); options = { max: 5, min: -5, orientation: "horizontal", step: 1 }; - el.slider(options); + element.slider(options); - el.slider("value", options.max - options.step); + element.slider( "value", options.max - options.step ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); - equal(el.slider("value"), options.max); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + equal(element.slider( "value" ), options.max); - handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); - equal(el.slider("value"), options.max); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + equal(element.slider( "value" ), options.max ); - el.slider("destroy"); + element.slider( "destroy" ); - el = $("
      "); + element = $( "
      " ); options = { max: 5, min: -5, orientation: "vertical", step: 1 }; - el.slider(options); + element.slider( options ); - el.slider("value", options.max - options.step); + element.slider( "value", options.max - options.step ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); - equal(el.slider("value"), options.max); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + equal(element.slider( "value" ), options.max ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); - equal(el.slider("value"), options.max); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + equal(element.slider( "value" ), options.max ); - el.slider("destroy"); + element.slider( "destroy" ); }); -test("keydown DOWN on handle decreases value by step, not less than min", function() { +test( "keydown DOWN on handle decreases value by step, not less than min", function() { expect( 4 ); - el = $("
      "); + element = $( "
      " ); options = { max: 5, min: -5, orientation: "horizontal", step: 1 }; - el.slider(options); + element.slider( options ); - el.slider("value", options.min + options.step); + element.slider( "value", options.min + options.step ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.DOWN }); - equal(el.slider("value"), options.min); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + equal(element.slider( "value" ), options.min); - handle().simulate("keydown", { keyCode: $.ui.keyCode.DOWN }); - equal(el.slider("value"), options.min); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + equal(element.slider( "value" ), options.min ); - el.slider("destroy"); + element.slider( "destroy" ); - el = $("
      "); + element = $( "
      " ); options = { max: 5, min: -5, orientation: "vertical", step: 1 }; - el.slider(options); + element.slider( options ); - el.slider("value", options.min + options.step); + element.slider( "value", options.min + options.step ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.DOWN }); - equal(el.slider("value"), options.min); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + equal(element.slider( "value" ), options.min); - handle().simulate("keydown", { keyCode: $.ui.keyCode.DOWN }); - equal(el.slider("value"), options.min); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + equal(element.slider( "value" ), options.min ); - el.slider("destroy"); + element.slider( "destroy" ); }); -test("keydown LEFT on handle decreases value by step, not less than min", function() { +test( "keydown LEFT on handle decreases value by step, not less than min", function() { expect( 4 ); - el = $("
      "); + element = $( "
      " ); options = { max: 5, min: -5, orientation: "horizontal", step: 1 }; - el.slider(options); + element.slider(options); - el.slider("value", options.min + options.step); + element.slider( "value", options.min + options.step ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.LEFT }); - equal(el.slider("value"), options.min); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); + equal(element.slider( "value" ), options.min ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.LEFT }); - equal(el.slider("value"), options.min); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); + equal(element.slider( "value" ), options.min ); - el.slider("destroy"); + element.slider( "destroy" ); - el = $("
      "); + element = $( "
      " ); options = { max: 5, min: -5, orientation: "vertical", step: 1 }; - el.slider(options); + element.slider( options ); - el.slider("value", options.min + options.step); + element.slider( "value", options.min + options.step ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.LEFT }); - equal(el.slider("value"), options.min); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); + equal(element.slider( "value" ), options.min ); - handle().simulate("keydown", { keyCode: $.ui.keyCode.LEFT }); - equal(el.slider("value"), options.min); + handle().simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); + equal(element.slider( "value" ), options.min ); - el.slider("destroy"); + element.slider( "destroy" ); }); -})(jQuery); +})( jQuery ); diff --git a/tests/unit/slider/slider_events.js b/tests/unit/slider/slider_events.js index d5e7dff45..92b0bdedd 100644 --- a/tests/unit/slider/slider_events.js +++ b/tests/unit/slider/slider_events.js @@ -1,7 +1,7 @@ /* * slider_events.js */ -(function($) { +(function( $ ) { module( "slider: events" ); @@ -10,9 +10,9 @@ module( "slider: events" ); // value (even if same as previous value), via mouse(mouseup) or keyboard(keyup) // or value method/option" test( "mouse based interaction", function() { - expect(4); + expect( 4 ); - var el = $( "#slider1" ) + var element = $( "#slider1" ) .slider({ start: function( event ) { equal( event.originalEvent.type, "mousedown", "start triggered by mousedown" ); @@ -28,15 +28,15 @@ test( "mouse based interaction", function() { } }); - el.find( ".ui-slider-handle" ).eq( 0 ) + element.find( ".ui-slider-handle" ).eq( 0 ) .simulate( "drag", { dx: 10, dy: 10 } ); }); test( "keyboard based interaction", function() { - expect(3); + expect( 3 ); // Test keyup at end of handle slide (keyboard) - var el = $( "#slider1" ) + var element = $( "#slider1" ) .slider({ start: function( event ) { equal( event.originalEvent.type, "keydown", "start triggered by keydown" ); @@ -52,17 +52,17 @@ test( "keyboard based interaction", function() { } }); - el.find( ".ui-slider-handle" ).eq( 0 ) + element.find( ".ui-slider-handle" ).eq( 0 ) .simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ) .simulate( "keypress", { keyCode: $.ui.keyCode.LEFT } ) .simulate( "keyup", { keyCode: $.ui.keyCode.LEFT } ); }); test( "programmatic event triggers", function() { - expect(6); + expect( 6 ); // Test value method - var el = $( "
      " ) + var element = $( "
      " ) .slider({ change: function() { ok( true, "change triggered by value method" ); @@ -71,17 +71,17 @@ test( "programmatic event triggers", function() { .slider( "value", 0 ); // Test values method - el = $( "
      " ) + element = $( "
      " ) .slider({ values: [ 10, 20 ], change: function() { ok( true, "change triggered by values method" ); } }) - .slider( "values", [80, 90] ); + .slider( "values", [ 80, 90 ] ); // Test value option - el = $( "
      " ) + element = $( "
      " ) .slider({ change: function() { ok( true, "change triggered by value option" ); @@ -90,66 +90,66 @@ test( "programmatic event triggers", function() { .slider( "option", "value", 0 ); // Test values option - el = $( "
      " ) + element = $( "
      " ) .slider({ values: [ 10, 20 ], change: function() { ok( true, "change triggered by values option" ); } }) - .slider( "option", "values", [80, 90] ); + .slider( "option", "values", [ 80, 90 ] ); }); test( "mouse based interaction part two: when handles overlap", function() { - expect(4); + expect( 4 ); - var el = $( "#slider1" ) + var element = $( "#slider1" ) .slider({ values: [ 0, 0, 0 ], start: function( event, ui ) { - equal(handles.index(ui.handle), 2, "rightmost handle activated when overlapping at minimum (#3736)"); + equal( handles.index( ui.handle ), 2, "rightmost handle activated when overlapping at minimum (#3736)" ); } }), - handles = el.find( ".ui-slider-handle" ); - handles.eq(0).simulate( "drag", { dx: 10 } ); - el.slider( "destroy" ); + handles = element.find( ".ui-slider-handle" ); + handles.eq( 0 ).simulate( "drag", { dx: 10 } ); + element.slider( "destroy" ); - el = $( "#slider1" ) + element = $( "#slider1" ) .slider({ values: [ 10, 10, 10 ], max: 10, start: function( event, ui ) { - equal(handles.index(ui.handle), 0, "leftmost handle activated when overlapping at maximum"); + equal( handles.index( ui.handle ), 0, "leftmost handle activated when overlapping at maximum" ); } }), - handles = el.find( ".ui-slider-handle" ); - handles.eq(0).simulate( "drag", { dx: -10 } ); - el.slider( "destroy" ); + handles = element.find( ".ui-slider-handle" ); + handles.eq( 0 ).simulate( "drag", { dx: -10 } ); + element.slider( "destroy" ); - el = $( "#slider1" ) + element = $( "#slider1" ) .slider({ values: [ 19, 20 ] }), - handles = el.find( ".ui-slider-handle" ); - handles.eq(0).simulate( "drag", { dx: 10 } ); - el.one("slidestart", function(event, ui) { - equal(handles.index(ui.handle), 0, "left handle activated if left was moved last"); + handles = element.find( ".ui-slider-handle" ); + handles.eq( 0 ).simulate( "drag", { dx: 10 } ); + element.one( "slidestart", function( event, ui ) { + equal( handles.index( ui.handle ), 0, "left handle activated if left was moved last" ); }); - handles.eq(0).simulate( "drag", { dx: 10 } ); - el.slider( "destroy" ); + handles.eq( 0 ).simulate( "drag", { dx: 10 } ); + element.slider( "destroy" ); - el = $( "#slider1" ) + element = $( "#slider1" ) .slider({ values: [ 19, 20 ] }), - handles = el.find( ".ui-slider-handle" ); - handles.eq(1).simulate( "drag", { dx: -10 } ); - el.one("slidestart", function(event, ui) { - equal(handles.index(ui.handle), 1, "right handle activated if right was moved last (#3467)"); + handles = element.find( ".ui-slider-handle" ); + handles.eq( 1 ).simulate( "drag", { dx: -10 } ); + element.one( "slidestart", function( event, ui ) { + equal( handles.index( ui.handle ), 1, "right handle activated if right was moved last (#3467)" ); }); - handles.eq(0).simulate( "drag", { dx: 10 } ); + handles.eq( 0 ).simulate( "drag", { dx: 10 } ); }); -}( jQuery ) ); +})( jQuery ); diff --git a/tests/unit/slider/slider_methods.js b/tests/unit/slider/slider_methods.js index 73b8eb739..75df230a6 100644 --- a/tests/unit/slider/slider_methods.js +++ b/tests/unit/slider/slider_methods.js @@ -1,99 +1,99 @@ /* * slider_methods.js */ -(function($) { +(function( $ ) { -module("slider: methods"); +module( "slider: methods" ); -test("init", function() { +test( "init", function() { expect(5); - $("
      ").appendTo("body").slider().remove(); - ok(true, ".slider() called on element"); + $( "
      " ).appendTo( "body" ).slider().remove(); + ok( true, ".slider() called on element" ); - $([]).slider().remove(); - ok(true, ".slider() called on empty collection"); + $( [] ).slider().remove(); + ok( true, ".slider() called on empty collection" ); - $("
      ").slider().remove(); - ok(true, ".slider() called on disconnected DOMElement"); + $( "
      " ).slider().remove(); + ok( true, ".slider() called on disconnected DOMElement" ); - var el = $("
      ").slider(); - el.slider("option", "foo"); - el.remove(); - ok(true, "arbitrary option getter after init"); + var element = $( "
      " ).slider(); + element.slider( "option", "foo" ); + element.remove(); + ok( true, "arbitrary option getter after init" ); - $("
      ").slider().slider("option", "foo", "bar").remove(); - ok(true, "arbitrary option setter after init"); + $( "
      " ).slider().slider( "option", "foo", "bar" ).remove(); + ok( true, "arbitrary option setter after init" ); }); -test("destroy", function() { +test( "destroy", function() { expect( 1 ); domEqual( "#slider1", function() { $( "#slider1" ).slider().slider( "destroy" ); }); }); -test("enable", function() { +test( "enable", function() { expect( 5 ); - var el, - expected = $("
      ").slider(), - actual = expected.slider("enable"); - equal(actual, expected, "enable is chainable"); + var element, + expected = $( "
      " ).slider(), + actual = expected.slider( "enable" ); + equal(actual, expected, "enable is chainable" ); - el = $("
      ").slider({ disabled: true }); - ok(el.hasClass("ui-state-disabled"), "slider has ui-state-disabled class before enable method call"); - ok(el.hasClass("ui-slider-disabled"), "slider has ui-slider-disabled class before enable method call"); - el.slider("enable"); - ok(!el.hasClass("ui-state-disabled"), "slider does not have ui-state-disabled class after enable method call"); - ok(!el.hasClass("ui-slider-disabled"), "slider does not have ui-slider-disabled class after enable method call"); + element = $( "
      " ).slider({ disabled: true }); + ok( element.hasClass( "ui-state-disabled" ), "slider has ui-state-disabled class before enable method call" ); + ok( element.hasClass( "ui-slider-disabled" ), "slider has ui-slider-disabled class before enable method call" ); + element.slider( "enable" ); + ok( !element.hasClass( "ui-state-disabled" ), "slider does not have ui-state-disabled class after enable method call" ); + ok( !element.hasClass( "ui-slider-disabled" ), "slider does not have ui-slider-disabled class after enable method call" ); }); -test("disable", function() { +test( "disable", function() { expect( 5 ); - var el, - expected = $("
      ").slider(), - actual = expected.slider("disable"); - equal(actual, expected, "disable is chainable"); + var element, + expected = $( "
      " ).slider(), + actual = expected.slider( "disable" ); + equal(actual, expected, "disable is chainable" ); - el = $("
      ").slider({ disabled: false }); - ok(!el.hasClass("ui-state-disabled"), "slider does not have ui-state-disabled class before disabled method call"); - ok(!el.hasClass("ui-slider-disabled"), "slider does not have ui-slider-disabled class before disable method call"); - el.slider("disable"); - ok(el.hasClass("ui-state-disabled"), "slider has ui-state-disabled class after disable method call"); - ok(el.hasClass("ui-slider-disabled"), "slider has ui-slider-disabled class after disable method call"); + element = $( "
      " ).slider({ disabled: false }); + ok( !element.hasClass( "ui-state-disabled" ), "slider does not have ui-state-disabled class before disabled method call" ); + ok( !element.hasClass( "ui-slider-disabled" ), "slider does not have ui-slider-disabled class before disable method call" ); + element.slider( "disable" ); + ok( element.hasClass( "ui-state-disabled" ), "slider has ui-state-disabled class after disable method call" ); + ok( element.hasClass( "ui-slider-disabled" ), "slider has ui-slider-disabled class after disable method call" ); }); -test("value", function() { +test( "value", function() { expect( 17 ); - $([false, "min", "max"]).each(function() { - var el = $("
      ").slider({ + $( [ false, "min", "max" ] ).each(function() { + var element = $( "
      " ).slider({ range: this, value: 5 }); - equal(el.slider("value"), 5, "range: " + this + " slider method get"); - equal(el.slider("value", 10), el, "value method is chainable"); - equal(el.slider("value"), 10, "range: " + this + " slider method set"); - el.remove(); + equal( element.slider( "value" ), 5, "range: " + this + " slider method get" ); + equal( element.slider( "value", 10), element, "value method is chainable" ); + equal( element.slider( "value" ), 10, "range: " + this + " slider method set" ); + element.remove(); }); - var el = $("
      ").slider({ + var element = $( "
      " ).slider({ min: -1, value: 0, max: 1 }); // min with value option vs value method - el.slider("option", "value", -2); - equal(el.slider("option", "value"), -2, "value option does not respect min"); - equal(el.slider("value"), -1, "value method get respects min"); - equal(el.slider("value", -2), el, "value method is chainable"); - equal(el.slider("option", "value"), -1, "value method set respects min"); + element.slider( "option", "value", -2 ); + equal( element.slider( "option", "value" ), -2, "value option does not respect min" ); + equal( element.slider( "value" ), -1, "value method get respects min" ); + equal( element.slider( "value", -2 ), element, "value method is chainable" ); + equal( element.slider( "option", "value" ), -1, "value method set respects min" ); // max with value option vs value method - el.slider("option", "value", 2); - equal(el.slider("option", "value"), 2, "value option does not respect max"); - equal(el.slider("value"), 1, "value method get respects max"); - equal(el.slider("value", 2), el, "value method is chainable"); - equal(el.slider("option", "value"), 1, "value method set respects max"); + element.slider( "option", "value", 2); + equal( element.slider( "option", "value" ), 2, "value option does not respect max" ); + equal( element.slider( "value" ), 1, "value method get respects max" ); + equal( element.slider( "value", 2 ), element, "value method is chainable" ); + equal( element.slider( "option", "value" ), 1, "value method set respects max" ); }); -//test("values", function() { -// ok(false, "missing test - untested code is broken code."); +//test( "values", function() { +// ok(false, "missing test - untested code is broken code." ); //}); -})(jQuery); +})( jQuery ); diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js index d354ef91c..f46dbde99 100644 --- a/tests/unit/slider/slider_options.js +++ b/tests/unit/slider/slider_options.js @@ -1,19 +1,50 @@ /* * slider_options.js */ -(function($) { +(function( $ ) { -var el, options; +var element, options; function handle() { - return el.find(".ui-slider-handle"); + return element.find( ".ui-slider-handle" ); } -module("slider: options"); +module( "slider: options" ); -test("max", function() { +test( "disabled", function(){ + expect( 8 ); + var count = 0; + + element = $( "#slider1" ).slider(); + element.bind( "slidestart", function() { + count++; + }); + + // enabled + ok( !element.hasClass( "ui-slider-disabled" ), "no disabled class" ); + equal( element.slider( "option", "disabled" ), false , "is not disabled" ); + + handle().simulate( "drag", { dx: 10 } ); + equal( count, 1, "slider moved" ); + + handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + equal( count, 2, "slider moved" ); + + // disabled + element.slider( "option", "disabled", true ); + ok( element.hasClass( "ui-slider-disabled" ), "has disabled class" ); + equal( element.slider( "option", "disabled" ), true, "is disabled" ); + + handle().simulate( "drag", { dx: 10 } ); + equal( count, 2, "slider did not move" ); + + handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + equal( count, 2, "slider did not move" ); +}); + +test( "max", function() { expect( 2 ); - el = $("
      "); + element = $( "
      " ); options = { max: 37, @@ -23,16 +54,16 @@ test("max", function() { value: 50 }; - el.slider(options); - ok(el.slider("option", "value") === options.value, "value option is not contained by max"); - ok(el.slider("value") === options.max, "value method is contained by max"); - el.slider("destroy"); + element.slider( options ); + ok(element.slider( "option", "value" ) === options.value, "value option is not contained by max" ); + ok(element.slider( "value" ) === options.max, "value method is contained by max" ); + element.slider( "destroy" ); }); -test("min", function() { +test( "min", function() { expect( 2 ); - el = $("
      "); + element = $( "
      " ); options = { max: 37, @@ -42,16 +73,16 @@ test("min", function() { value: 2 }; - el.slider(options); - ok(el.slider("option", "value") === options.value, "value option is not contained by min"); - ok(el.slider("value") === options.min, "value method is contained by min"); - el.slider("destroy"); + element.slider( options ); + ok( element.slider( "option", "value" ) === options.value, "value option is not contained by min" ); + ok( element.slider( "value" ) === options.min, "value method is contained by min" ); + element.slider( "destroy" ); }); -test("orientation", function() { +test( "orientation", function() { expect( 6 ); - el = $("#slider1"); + element = $( "#slider1" ); options = { max: 2, @@ -60,14 +91,14 @@ test("orientation", function() { value: 1 }; - var percentVal = (options.value - options.min) / (options.max - options.min) * 100; + var percentVal = ( options.value - options.min ) / ( options.max - options.min ) * 100; - el.slider(options).slider("option", "orientation", "horizontal"); - ok(el.is(".ui-slider-horizontal"), "horizontal slider has class .ui-slider-horizontal"); - ok(!el.is(".ui-slider-vertical"), "horizontal slider does not have class .ui-slider-vertical"); - equal(handle()[0].style.left, percentVal + "%", "horizontal slider handle is positioned with left: %"); + element.slider( options ).slider( "option", "orientation", "horizontal" ); + ok( element.is( ".ui-slider-horizontal" ), "horizontal slider has class .ui-slider-horizontal" ); + ok( !element.is( ".ui-slider-vertical" ), "horizontal slider does not have class .ui-slider-vertical" ); + equal( handle()[0].style.left, percentVal + "%", "horizontal slider handle is positioned with left: %" ); - el.slider("destroy"); + element.slider( "destroy" ) ; options = { max: 2, @@ -76,100 +107,199 @@ test("orientation", function() { value: -1 }; - percentVal = (options.value - options.min) / (options.max - options.min) * 100; + percentVal = ( options.value - options.min ) / ( options.max - options.min ) * 100; - el.slider(options).slider("option", "orientation", "vertical"); - ok(el.is(".ui-slider-vertical"), "vertical slider has class .ui-slider-vertical"); - ok(!el.is(".ui-slider-horizontal"), "vertical slider does not have class .ui-slider-horizontal"); - equal(handle()[0].style.bottom, percentVal + "%", "vertical slider handle is positioned with bottom: %"); + element.slider( options ).slider( "option", "orientation", "vertical" ); + ok( element.is( ".ui-slider-vertical" ), "vertical slider has class .ui-slider-vertical" ); + ok( !element.is( ".ui-slider-horizontal" ), "vertical slider does not have class .ui-slider-horizontal" ); + equal( handle()[0].style.bottom, percentVal + "%", "vertical slider handle is positioned with bottom: %" ); - el.slider("destroy"); + element.slider( "destroy" ); }); -//test("range", function() { -// ok(false, "missing test - untested code is broken code."); -//}); - //spec: http://wiki.jqueryui.com/Slider#specs // value option/method: the value option is not restricted by min/max/step. // What is returned by the value method is restricted by min (>=), max (<=), and step (even multiple) -test("step", function() { +test( "step", function() { expect( 9 ); - var el = $("
      ").slider({ + element = $( "
      " ).slider({ min: 0, value: 0, step: 10, max: 100 }); - equal( el.slider("value"), 0 ); + equal( element.slider( "value" ), 0 ); - el.slider("value", 1); - equal( el.slider("value"), 0 ); + element.slider( "value", 1 ); + equal( element.slider( "value" ), 0 ); - el.slider("value", 9); - equal( el.slider("value"), 10 ); + element.slider( "value", 9 ); + equal( element.slider( "value" ), 10 ); - el.slider("value", 11); - equal( el.slider("value"), 10 ); + element.slider( "value", 11 ); + equal( element.slider( "value" ), 10 ); - el.slider("value", 19); - equal( el.slider("value"), 20 ); + element.slider( "value", 19 ); + equal( element.slider( "value" ), 20 ); - el = $("
      ").slider({ + element = $( "
      " ).slider({ min: 0, value: 0, step: 20, max: 100 }); - el.slider("value", 0); + element.slider( "value", 0 ); - el.slider("option", "value", 1); - equal( el.slider("value"), 0 ); + element.slider( "option", "value", 1 ); + equal( element.slider( "value" ), 0 ); - el.slider("option", "value", 9); - equal( el.slider("value"), 0 ); + element.slider( "option", "value", 9 ); + equal( element.slider( "value" ), 0 ); - el.slider("option", "value", 11); - equal( el.slider("value"), 20 ); + element.slider( "option", "value", 11 ); + equal( element.slider( "value" ), 20 ); - el.slider("option", "value", 19); - equal( el.slider("value"), 20 ); + element.slider( "option", "value", 19 ); + equal( element.slider( "value" ), 20 ); - el.slider("destroy"); + element.slider( "destroy" ); }); -//test("value", function() { -// ok(false, "missing test - untested code is broken code."); +//test( "value", function() { +// ok(false, "missing test - untested code is broken code." ); //}); -test("values", function() { +test( "values", function() { expect( 2 ); // testing multiple ranges on the same page, the object reference to the values // property is preserved via multiple range elements, so updating options.values // of 1 slider updates options.values of all the others var ranges = $([ - document.createElement("div"), - document.createElement("div") + document.createElement( "div" ), + document.createElement( "div" ) ]).slider({ - range: true, + range: true, values: [ 25, 75 ] }); notStrictEqual( - ranges.eq(0).data("uiSlider").options.values, - ranges.eq(1).data("uiSlider").options.values, + ranges.eq( 0 ).data( "ui-slider" ).options.values, + ranges.eq( 1 ).data( "ui-slider" ).options.values, "multiple range sliders should not have a reference to the same options.values array" ); - ranges.eq(0).slider("values", 0, 10); + ranges.eq( 0 ).slider( "values", 0, 10 ); notEqual( - ranges.eq(0).slider("values", 0), - ranges.eq(1).slider("values", 0), + ranges.eq( 0 ).slider( "values", 0 ), + ranges.eq( 1 ).slider( "values", 0 ), "the values for multiple sliders should be different" ); }); -})(jQuery); +test( "range", function() { + expect( 27 ); + var range; + + // min + element = $( "
      " ).slider({ + range: "min", + min: 1, + max: 10, + step: 1 + }); + + equal( element.find( ".ui-slider-handle" ).length, 1, "range min, one handle" ); + equal( element.find( ".ui-slider-range-min" ).length, 1, "range min" ); + element.slider( "destroy" ); + + // max + element = $( "
      " ).slider({ + range: "max", + min: 1, + max: 10, + step: 1 + }); + + equal( element.find( ".ui-slider-handle" ).length, 1, "range max, one handle" ); + equal( element.find( ".ui-slider-range-max" ).length, 1, "range max" ); + element.slider( "destroy" ); + + // true + element = $( "
      " ).slider({ + range: true, + min: 1, + max: 10, + step: 1 + }); + + range = element.find( ".ui-slider-range" ); + equal( element.find( ".ui-slider-handle" ).length, 2, "range true, two handles" ); + ok( !range.is( ".ui-slider-range-min" ), "range true" ); + ok( !range.is( ".ui-slider-range-max" ), "range true" ); + element.slider( "destroy" ); + + // Change range from min to max + element = $( "
      " ).slider({ + range: "min", + min: 1, + max: 10, + step: 1 + }).slider( "option", "range", "max" ); + + equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from min to max, one handle" ); + equal( element.find( ".ui-slider-range-min" ).length, 0, "range switch from min to max" ); + equal( element.find( ".ui-slider-range-max" ).length, 1, "range switch from min to max" ); + element.slider( "destroy" ); + + // Change range from max to min + element = $( "
      " ).slider({ + range: "max", + min: 1, + max: 10, + step: 1 + }).slider( "option", "range", "min" ); + + equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from max to min, one handle" ); + equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from max to min" ); + equal( element.find( ".ui-slider-range-min" ).length, 1, "range switch from max to min" ); + element.slider( "destroy" ); + + // Change range from max to true + element = $( "
      " ).slider({ + range: "max", + min: 1, + max: 10, + step: 1 + }).slider( "option", "range", true ); + + equal( element.find( ".ui-slider-handle" ).length, 2, "range switch from max to true, two handles" ); + equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from max to true" ); + equal( element.find( ".ui-slider-range-min" ).length, 0, "range switch from max to true" ); + equal( element.slider( "option", "value" ), 0 , "option value" ); + equal( element.slider( "value" ), 1 , "value" ); + deepEqual( element.slider( "option", "values" ), [1, 1], "option values" ); + deepEqual( element.slider( "values" ), [1, 1], "values" ); + element.slider( "destroy" ); + + // Change range from true to min + element = $( "
      " ).slider({ + range: true, + min: 1, + max: 10, + step: 1 + }).slider( "option", "range", "min" ); + + equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from true to min, one handle" ); + equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from true to min" ); + equal( element.find( ".ui-slider-range-min" ).length, 1, "range switch from true to min" ); + equal( element.slider( "option", "value" ), 1, "value" ); + equal( element.slider( "value" ), 1 , "value" ); + equal( element.slider( "option", "values" ), null, "values" ); + deepEqual( element.slider( "values" ), [] , "values" ); + element.slider( "destroy" ); +}); + +})( jQuery ); diff --git a/tests/unit/sortable/all.html b/tests/unit/sortable/all.html index 25d437856..060883ef6 100644 --- a/tests/unit/sortable/all.html +++ b/tests/unit/sortable/all.html @@ -4,7 +4,7 @@ jQuery UI Sortable Test Suite - + diff --git a/tests/unit/sortable/sortable.html b/tests/unit/sortable/sortable.html index c23a15854..6e326a865 100644 --- a/tests/unit/sortable/sortable.html +++ b/tests/unit/sortable/sortable.html @@ -63,6 +63,27 @@
    1. Item 5
    2. + + + + + + + + + + + + + + + + + + + +
      12
      34
      56
      78
      +
      diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js index cf35aedb1..fe50be002 100644 --- a/tests/unit/sortable/sortable_options.js +++ b/tests/unit/sortable/sortable_options.js @@ -185,11 +185,41 @@ test("{ opacity: 1 }", function() { test("{ placeholder: false }, default", function() { ok(false, "missing test - untested code is broken code."); }); +*/ +test( "{ placeholder: String }", function() { + expect( 1 ); -test("{ placeholder: String }", function() { - ok(false, "missing test - untested code is broken code."); + var element = $( "#sortable" ).sortable({ + placeholder: "test", + start: function( event, ui ) { + ok( ui.placeholder.hasClass( "test" ), "placeholder has class" ); + } + }); + + element.find( "li" ).eq( 0 ).simulate( "drag", { + dy: 1 + }); }); +test( "{ placholder: String } tr", function() { + expect( 3 ); + + var element = $( "#sortable-table tbody" ).sortable({ + placeholder: "test", + start: function( event, ui ) { + ok( ui.placeholder.hasClass( "test" ), "placeholder has class" ); + equal( ui.placeholder.children().length, 1, "placeholder tr contains a td" ); + equal( ui.placeholder.children().html(), $( " " ).html(), + "placeholder td has content for forced dimensions" ); + } + }); + + element.find( "tr" ).eq( 0 ).simulate( "drag", { + dy: 1 + }); +}); + +/* test("{ revert: false }, default", function() { ok(false, "missing test - untested code is broken code."); }); diff --git a/tests/unit/spinner/all.html b/tests/unit/spinner/all.html index abc19e671..b6df4d460 100644 --- a/tests/unit/spinner/all.html +++ b/tests/unit/spinner/all.html @@ -4,7 +4,7 @@ jQuery UI Spinner Test Suite - + diff --git a/tests/unit/spinner/spinner_core.js b/tests/unit/spinner/spinner_core.js index a1179bb35..bea5f9122 100644 --- a/tests/unit/spinner/spinner_core.js +++ b/tests/unit/spinner/spinner_core.js @@ -80,6 +80,33 @@ test( "keydown PAGE_DOWN on input, decreases value not less than min", function( equal( element.val(), 20 ); }); +asyncTest( "blur input while spinning with UP", function() { + expect( 3 ); + var value, + element = $( "#spin" ).val( 10 ).spinner(); + + function step1() { + element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + equal( element.val(), 11 ); + setTimeout( step2, 750 ); + } + + function step2() { + value = element.val(); + ok( value > 11, "repeating while key is down" ); + element[0].blur(); + setTimeout( step3, 250 ); + } + + function step3() { + equal( element.val(), value, "stopped repeating on blur" ); + start(); + } + + element[ 0 ].focus(); + setTimeout( step1 ); +}); + test( "mouse click on up button, increases value not greater than max", function() { expect( 3 ); var element = $( "#spin" ).val( 18 ).spinner({ diff --git a/tests/unit/subsuite.js b/tests/unit/subsuite.js index 47d87bfe4..1efb2f834 100644 --- a/tests/unit/subsuite.js +++ b/tests/unit/subsuite.js @@ -4,6 +4,7 @@ var versions = [ "1.6", "1.6.1", "1.6.2", "1.6.3", "1.6.4", "1.7", "1.7.1", "1.7.2", "1.8.0", "1.8.1", "1.8.2", "1.8.3", + "1.9.0", "1.9.1", "git" ], additionalTests = { diff --git a/tests/unit/tabs/all.html b/tests/unit/tabs/all.html index 63af7ac91..ab96cc3aa 100644 --- a/tests/unit/tabs/all.html +++ b/tests/unit/tabs/all.html @@ -4,7 +4,7 @@ jQuery UI Tabs Test Suite - + diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index 42fdf4f9e..d2403beeb 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -28,9 +28,9 @@ QUnit.reset = function() { QUnit.config.requireExpects = true; QUnit.config.urlConfig.push({ - id: "min", - label: "Minified source", - tooltip: "Load minified source files instead of the regular unminified ones." + id: "min", + label: "Minified source", + tooltip: "Load minified source files instead of the regular unminified ones." }); TestHelpers.loadResources = QUnit.urlParams.min ? diff --git a/tests/unit/tooltip/all.html b/tests/unit/tooltip/all.html index cb1c14095..2b1ce5008 100644 --- a/tests/unit/tooltip/all.html +++ b/tests/unit/tooltip/all.html @@ -4,7 +4,7 @@ jQuery UI Tooltip Test Suite - + diff --git a/tests/unit/widget/all.html b/tests/unit/widget/all.html index 461b2a931..eeec4d0d9 100644 --- a/tests/unit/widget/all.html +++ b/tests/unit/widget/all.html @@ -4,7 +4,7 @@ jQuery UI Widget Test Suite - + diff --git a/tests/visual/accordion/icons.html b/tests/visual/accordion/icons.html index 9444f2bf9..6cf915743 100644 --- a/tests/visual/accordion/icons.html +++ b/tests/visual/accordion/icons.html @@ -4,7 +4,7 @@ Accordion Visual Test - + diff --git a/tests/visual/addClass/queue.html b/tests/visual/addClass/queue.html index 5cd70548e..2b21a4e5a 100644 --- a/tests/visual/addClass/queue.html +++ b/tests/visual/addClass/queue.html @@ -4,7 +4,7 @@ addClass Visual Test : Queue - +