diff options
author | Kevin Cupp <kevin.cupp@gmail.com> | 2015-07-15 21:10:19 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2016-10-04 15:22:14 -0400 |
commit | 87eab46a589031d781299937f95f22bf61b5ef27 (patch) | |
tree | d17f5c5876bf06ee6a3e1dc5244edf40abe46675 /tests/unit | |
parent | b9d687deb58cce5f4c6e27dace9cb172e291698c (diff) | |
download | jquery-ui-87eab46a589031d781299937f95f22bf61b5ef27.tar.gz jquery-ui-87eab46a589031d781299937f95f22bf61b5ef27.zip |
Sortable: Setting table row placeholder height to be same as sorted row
Fixes #13662
Closes gh-1578
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/sortable/options.js | 52 | ||||
-rw-r--r-- | tests/unit/sortable/sortable.html | 21 |
2 files changed, 66 insertions, 7 deletions
diff --git a/tests/unit/sortable/options.js b/tests/unit/sortable/options.js index fa0c487b7..30929a501 100644 --- a/tests/unit/sortable/options.js +++ b/tests/unit/sortable/options.js @@ -255,15 +255,55 @@ test("{ dropOnEmpty: true }, default", function() { test("{ dropOnEmpty: false }", function() { ok(false, "missing test - untested code is broken code."); }); +*/ -test("{ forcePlaceholderSize: false }, default", function() { - ok(false, "missing test - untested code is broken code."); -}); +QUnit.test( "{ forcePlaceholderSize: false } table rows", function( assert ) { + assert.expect( 1 ); -test("{ forcePlaceholderSize: true }", function() { - ok(false, "missing test - untested code is broken code."); -}); + var element = $( "#sortable-table2 tbody" ); + + element.sortable( { + placeholder: "test", + forcePlaceholderSize: false, + start: function( event, ui ) { + assert.notEqual( ui.placeholder.height(), ui.item.height(), + "placeholder is same height as item" ); + } + } ); + + // This row has a non-standard height + $( "tr", element ).eq( 0 ).simulate( "drag", { + dy: 1 + } ); +} ); +QUnit.test( "{ forcePlaceholderSize: true } table rows", function( assert ) { + assert.expect( 2 ); + + // Table should have the placeholder's height set the same as the row we're dragging + var element = $( "#sortable-table2 tbody" ); + + element.sortable( { + placeholder: "test", + forcePlaceholderSize: true, + start: function( event, ui ) { + assert.equal( ui.placeholder.height(), ui.item.height(), + "placeholder is same height as item" ); + } + } ); + + // First row has a non-standard height + $( "tr", element ).eq( 0 ).simulate( "drag", { + dy: 1 + } ); + + // Second row's height is normal + $( "tr", element ).eq( 1 ).simulate( "drag", { + dy: 1 + } ); +} ); + +/* test("{ forceHelperSize: false }, default", function() { ok(false, "missing test - untested code is broken code."); }); diff --git a/tests/unit/sortable/sortable.html b/tests/unit/sortable/sortable.html index 8bfbd3370..4ea5b0fc6 100644 --- a/tests/unit/sortable/sortable.html +++ b/tests/unit/sortable/sortable.html @@ -22,7 +22,8 @@ border-width: 0; height:19px; } - #sortable-table { + #sortable-table, + #sortable-table2 { width: 100%; } </style> @@ -105,6 +106,24 @@ </tbody> </table> +<!-- This table has rows of varying height --> +<table id="sortable-table2"> + <tbody> + <tr> + <td>1<br>1</td> + <td>1</td> + </tr> + <tr> + <td>2</td> + <td>2</td> + </tr> + <tr> + <td>3</td> + <td>3</td> + </tr> + </tbody> +</table> + <div id="sortable-images"> <img src="../../images/jqueryui_32x32.png" alt=""> <img src="../../images/jqueryui_32x32.png" alt=""> |