aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2013-03-03 13:48:01 +0100
committerFelix Nagel <info@felixnagel.com>2013-03-03 13:48:01 +0100
commitdffe8f66109714af2d4ed8f582af4cf3439433e3 (patch)
treed83889fc566946bd35e4f8dc866f2aac5e4b095a /tests
parentd94e217065745e9ad0638cf68d3d973ffe44035a (diff)
parent6d3a1e1fe8cc21f385456ea26075f3909136a589 (diff)
downloadjquery-ui-dffe8f66109714af2d4ed8f582af4cf3439433e3.tar.gz
jquery-ui-dffe8f66109714af2d4ed8f582af4cf3439433e3.zip
Merge branch 'master' into selectmenu
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/draggable/draggable.html9
-rw-r--r--tests/unit/draggable/draggable_options.js35
-rw-r--r--tests/unit/droppable/droppable.html1
-rw-r--r--tests/unit/droppable/droppable_events.js46
-rw-r--r--tests/unit/effects/effects.html6
-rw-r--r--tests/unit/effects/effects_core.js26
-rw-r--r--tests/unit/position/position_core.js26
-rw-r--r--tests/unit/slider/slider_options.js8
-rw-r--r--tests/unit/sortable/sortable.html21
-rw-r--r--tests/unit/sortable/sortable_options.js34
-rw-r--r--tests/unit/spinner/spinner_core.js27
11 files changed, 221 insertions, 18 deletions
diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html
index cd068eb20..50bed8caf 100644
--- a/tests/unit/draggable/draggable.html
+++ b/tests/unit/draggable/draggable.html
@@ -6,6 +6,12 @@
<script src="../../jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
+
+ <style>
+ /* See #9077 */
+ #draggable3, #draggable4 { z-index: 100; }
+ </style>
+
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
@@ -39,13 +45,14 @@
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
-
<div id="main"></div>
<div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div>
<div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span>Absolute</span></div>
<div style='width: 1px; height: 1000px;'></div>
<div style="position: absolute; width: 1px; height: 2000px;"></div>
+<div id="draggable3"></div>
+<div id="draggable4"></div>
</div>
diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js
index a3f7169f2..8496d6182 100644
--- a/tests/unit/draggable/draggable_options.js
+++ b/tests/unit/draggable/draggable_options.js
@@ -723,4 +723,39 @@ test("{ zIndex: 10 }", function() {
});
+test( "{ stack }", function() {
+ expect( 4 );
+
+ var draggable1 = $( "#draggable1" ),
+ draggable2 = $( "#draggable2" ),
+ draggable3 = $( "#draggable3" ),
+ draggable4 = $( "#draggable4" );
+
+ // Set z-index as an inline style.
+ $( "#draggable1, #draggable2" )
+ .css( "zIndex", 100 )
+ .draggable({
+ stack: "#draggable1, #draggable2"
+ });
+ // Have z-index applied via CSS, see #9077
+ $( "#draggable3, #draggable4" )
+ .draggable({
+ stack: "#draggable3, #draggable4"
+ });
+
+ draggable1.simulate( "drag", {
+ dx: 1,
+ dy: 1
+ });
+ draggable3.simulate( "drag", {
+ dx: 1,
+ dy: 1
+ });
+
+ equal( draggable1.css( "zIndex" ), 102);
+ equal( draggable2.css( "zIndex" ), 101);
+ equal( draggable3.css( "zIndex" ), 102);
+ equal( draggable4.css( "zIndex" ), 101);
+});
+
})(jQuery);
diff --git a/tests/unit/droppable/droppable.html b/tests/unit/droppable/droppable.html
index 7cd5eb0f5..d084464c2 100644
--- a/tests/unit/droppable/droppable.html
+++ b/tests/unit/droppable/droppable.html
@@ -42,6 +42,7 @@
<div id="draggable1" style="width: 25px; height: 25px;">Draggable</div>
<div id="droppable1" style="width: 100px; height: 100px;">Droppable</div>
+<div id="droppable2" style="width: 100px; height: 100px;">Droppable</div>
<div style='width:1000px;height:1000px;'>&nbsp;</div>
</div>
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 = $( "<div>" )
+ .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/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 @@
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
-<div class="hidden test"></div>
+<div id="elem" class="test">
+</div>
+<div class="hidden test">
+ <div>.</div>
+</div>
<div class="animateClass test">
<h2>Child Element Test</h2>
</div>
diff --git a/tests/unit/effects/effects_core.js b/tests/unit/effects/effects_core.js
index c9b1e1b4a..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;
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/slider/slider_options.js b/tests/unit/slider/slider_options.js
index dfa94696a..f46dbde99 100644
--- a/tests/unit/slider/slider_options.js
+++ b/tests/unit/slider/slider_options.js
@@ -16,7 +16,7 @@ test( "disabled", function(){
var count = 0;
element = $( "#slider1" ).slider();
- element.on( "slidestart", function() {
+ element.bind( "slidestart", function() {
count++;
});
@@ -180,13 +180,13 @@ test( "values", function() {
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"
);
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 @@
<li>Item 5</li>
</ul>
+<table id="sortable-table">
+ <tbody>
+ <tr>
+ <td>1</td>
+ <td>2</td>
+ </tr>
+ <tr>
+ <td>3</td>
+ <td>4</td>
+ </tr>
+ <tr>
+ <td>5</td>
+ <td>6</td>
+ </tr>
+ <tr>
+ <td>7</td>
+ <td>8</td>
+ </tr>
+ </tbody>
+</table>
+
</div>
</body>
</html>
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(), $( "<span>&#160;</span>" ).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/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({