Skip to content

Instantly share code, notes, and snippets.

@mlewand
Created September 16, 2014 08:41
Show Gist options
  • Save mlewand/d5674183bf62f6b1c85e to your computer and use it in GitHub Desktop.
Save mlewand/d5674183bf62f6b1c85e to your computer and use it in GitHub Desktop.
Sample code to check Quail test cases count.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>title</title>
</head>
<body>
<div id="sampleContent">
<h1>Short date 12-04-12</h1>
<p>Short date 12-04-12</p>
</div>
<script src="lib/jquery/jquery.js"></script>
<script src="dist/quail.jquery.js"></script>
<script>
function testCollectionComplete( collection ) {
// Iterating over Test objects...
// In this case we're limited to one test, so we can exec assertion
// in each function.
collection.each( function( testIndex, testInstance ) {
// Count of tested cases.
var actualCases = testInstance.length,
// Expected count of cases.
expectedCases = 2;
// Lets check if the expected and actual cases count is the same.
if ( actualCases === expectedCases ) {
alert( 'OK' );
} else {
alert( 'Invalid len ' + actualCases + ', expected: ' + expectedCases );
}
} );
}
setTimeout( function() {
// Execute Quail checking after small timeout.
$( '#sampleContent' ).quail( {
guideline : [ 'KINGUseLongDateFormat' ],
jsonPath: 'dist/',
testCollectionComplete: function ( eventName, testCollection ) {
testCollectionComplete( testCollection );
}
} );
}, 300 );
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment