This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Table: Add individual-modules tests for reflow and columntoggle
Re gh-5987
- Loading branch information
Gabriel Schulhof
committed
Jun 19, 2014
1 parent
4274227
commit e5d1724
Showing
2 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>jQuery Mobile Collapsible Test Suite</title> | ||
|
||
<script src="../../../external/requirejs/require.js"></script> | ||
<script src="../../../js/requirejs.config.js"></script> | ||
<script src="../../../js/jquery.tag.inserter.js"></script> | ||
<script src="../../../tests/jquery.testHelper.js"></script> | ||
|
||
<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/> | ||
<link rel="stylesheet" href="../../../external/qunit/qunit.css"/> | ||
<link rel="stylesheet" href="../../jqm-tests.css"/> | ||
<script src="../../../external/qunit/qunit.js"></script> | ||
<script> | ||
$.testHelper.asyncLoad([ | ||
[ | ||
"widgets/table.reflow", | ||
"widgets/table.columntoggle" | ||
], | ||
[ | ||
"../../jquery.setNameSpace.immediately.js" | ||
], | ||
[ | ||
"table_core.js" | ||
] | ||
]); | ||
</script> | ||
|
||
<script src="../../swarminject.js"></script> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
|
||
<table id="reflow-test" data-nstest-mode="reflow"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Color</th> | ||
<th>Shape</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>Orange</td> | ||
<td>Orange</td> | ||
<td>Round</td> | ||
</tr> | ||
<tr> | ||
<td>Watermelon</td> | ||
<td>Green</td> | ||
<td>Oval</td> | ||
</tr> | ||
<tr> | ||
<td>Banana</td> | ||
<td>Yellow</td> | ||
<td>Sickle</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
<table id="columntoggle-test" data-nstest-mode="columntoggle"> | ||
<thead> | ||
<tr> | ||
<th data-nstest-priority="permanent">Name</th> | ||
<th data-nstest-priority="1">Color</th> | ||
<th data-nstest-priority="2">Shape</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>Orange</td> | ||
<td>Orange</td> | ||
<td>Round</td> | ||
</tr> | ||
<tr> | ||
<td>Watermelon</td> | ||
<td>Green</td> | ||
<td>Oval</td> | ||
</tr> | ||
<tr> | ||
<td>Banana</td> | ||
<td>Yellow</td> | ||
<td>Sickle</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
test( "Reflow table is enhanced correctly", function() { | ||
var table = $( "#reflow-test" ).table(); | ||
|
||
deepEqual( table.hasClass( "ui-table" ), true, "Table has class 'ui-table'" ); | ||
deepEqual( table.hasClass( "ui-table-reflow" ), true, "Table has class 'ui-table-reflow'" ); | ||
deepEqual( | ||
table | ||
.children( "thead" ) | ||
.children() | ||
.children() | ||
.is( table.children( "thead" ) | ||
.children() | ||
.children( "[data-" + $.mobile.ns + "colstart]" ) ), true, | ||
"All thead cells have the '[data-colstart]' attribute" ); | ||
deepEqual( table.children( "tbody" ).children().children().is( function() { | ||
return ( $( this ).children( "b.ui-table-cell-label" ).length !== 1 ); | ||
}), false, "All tbody cells have a bold child with class ui-table-cell-label" ); | ||
}); | ||
|
||
test( "Columntoggle table is enhanced correctly", function() { | ||
var table = $( "#columntoggle-test" ).table(), | ||
correctPriorities = true; | ||
|
||
deepEqual( table.hasClass( "ui-table" ), true, "Table has class 'ui-table'" ); | ||
deepEqual( table.hasClass( "ui-table-columntoggle" ), true, | ||
"Table has class 'ui-table-column-toggle'" ); | ||
deepEqual( $( "a[href='#columntoggle-test-popup']#columntoggle-test-button" ).length, 1, | ||
"A button with id 'columntoggle-test-button' and href='#columntoggle-test-popup' exists" ); | ||
deepEqual( $( "#columntoggle-test-popup:data(mobile-popup)" ).length, 1, | ||
"A popup widget with id 'columntoggle-test-popup' exists" ); | ||
|
||
// Try to find incorrectly assigned priority classes | ||
table.children( "thead" ).children().children().each( function( index ) { | ||
var cell = $( this ), | ||
priority = cell.attr( "data-" + $.mobile.ns + "priority" ); | ||
|
||
if ( priority ) { | ||
correctPriorities = | ||
( table | ||
.children( "tbody" ) | ||
.children() | ||
.children( ":nth(" + index + ")" ) | ||
.filter( ":not(.ui-table-priority-" + priority + ")" ).length === 0 ); | ||
} | ||
|
||
// If incorrect priorities have been identified, stop .each()-ing | ||
return correctPriorities; | ||
}); | ||
|
||
deepEqual( correctPriorities, true, | ||
"All tbody cells have priority classes assigned in accordance with their header " + | ||
"'data-priority' value" ); | ||
}); |