Permalink
Browse files

Table: Test setColumnVisibility() when there's a popup

  • Loading branch information...
gabrielschulhof authored and arschmitz committed Jun 17, 2014
1 parent 4fb2fc8 commit 0605d81b9bc69963d25a52391ef421fc33c5e0fa
Showing with 45 additions and 1 deletion.
  1. +27 −1 tests/unit/table/columntoggle-table-tests.html
  2. +18 −0 tests/unit/table/columntoggle_table_core.js
@@ -33,7 +33,6 @@
<script src="../../../external/qunit/qunit.js"></script>
<script>
$.testHelper.asyncLoad([
[ "widgets/page" ],
[
"widgets/table.columntoggle.popup"
],
@@ -216,6 +215,33 @@
</tr>
</tbody>
</table>
<table id="setColumnVisibility-test" data-nstest-role="table" data-nstest-mode="columntoggle" class="ui-responsive">
<thead>
<tr>
<th data-nstest-priority="2" data-column-under-test>Rank</th>
<th>Movie Title</th>
<th data-nstest-priority="3">Year</th>
<th data-nstest-priority="1"><abbr title="Rotten Tomato Rating">Rating</abbr></th>
<th data-nstest-priority="5">Reviews</th>
</tr>
</thead>
<tbody>
<tr>
<th data-column-under-test>1</th>
<td><a href="http://en.wikipedia.org/wiki/Citizen_Kane" data-nstest-rel="external">Citizen Kane</a></td>
<td>1941</td>
<td>100%</td>
<td>74</td>
</tr>
<tr>
<th data-column-under-test>2</th>
<td><a href="http://en.wikipedia.org/wiki/Casablanca_(film)" data-nstest-rel="external">Casablanca</a></td>
<td>1942</td>
<td>97%</td>
<td>64</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
@@ -368,3 +368,21 @@ test( "Locked columns stay locked after row/column addition", function() {
deepEqual( $( "#refresh-hidden-column-test-popup" ).find( "input" ).eq( 4 ).prop( "checked" ),
true, "Checked checkbox remains checked after column addition and table refresh" );
});
test( "setColumnVisibility() correctly resolves column from index/cell", function() {
var table = $( "#setColumnVisibility-test" ),
affectedCells = $( "[data-column-under-test]", table[ 0 ] ),
input = affectedCells.eq( 0 ).data( $.camelCase( $.mobile.ns + "input" ) );
table.table( "setColumnVisibility", 0, true );
deepEqual( input.prop( "checked" ), true,
"Turning on visibility by index affects only the expected cells" );
table.table( "setColumnVisibility", affectedCells.eq( 0 ), false );
deepEqual( input.prop( "checked" ), false,
"Turning off visibility by thead cell affects only the expected cells" );
table.table( "setColumnVisibility", affectedCells.eq( 2 ), true );
deepEqual( input.prop( "checked" ), true,
"Turning on visibility by tbody cell affects only the expected cells" );
});

0 comments on commit 0605d81

Please sign in to comment.