Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v1.2.2
Fetching contributors…

Cannot retrieve contributors at this time

138 lines (108 sloc) 3.989 kb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Drive jQuery plugin :: unit tests</title>
<script src="http://www.google.com/jsapi"></script>
<script>
// load latest version of jQuery from Google AJAX libs
// http://code.google.com/apis/ajaxlibs/
google.load("jquery", "1");
</script>
<script type="text/javascript" src="jquery.drive.js"></script>
<script>
function log_test(n, message) {
$.drive('#container-left div#test-' + n + '.middle-size').html(message + ': ');
$.drive('#container-left div#test-' + n + '.middle-size span').html('???');
}
function run_tests() {
$('#container-right').empty();
/*** unit tests here ***/
try {
// test 0
log_test(0, "$.drive({selector: '#container-right #div-0.middle-size.bg-green'})");
$.drive({
selector: '#container-right #div-0.middle-size.bg-green',
success: function() {
$('#test-0 span').css('color', 'green').html('success!');
}
});
// test 1
log_test(1, "$.drive({selector: '#div-1.middle-size.bg-blue', context: '#container-right'})");
$.drive({
selector: 'div#div-1.middle-size.bg-blue',
context: '#container-right',
success: function() {
$('#test-1 span').css('color', 'green').html('success!');
}
});
// test 2
log_test(2, "$.drive('#container-right div#div-2.middle-size.bg-red')");
$.drive('#container-right div#div-2.middle-size.bg-red', function() {
$('#test-2 span').css('color', 'green').html('success!');
});
// test 3
log_test(3, "$.drive('#div-3.middle-size.bg-green', $('#container-right'))");
$.drive('#div-3.middle-size.bg-green', $('#container-right'), function() {
$('#test-3 span').css('color', 'green').html('success!');
});
// test 4
log_test(4, "$('#container-right div#div-4.middle-size.bg-blue').drive( )");
$('#container-right div#div-4.middle-size.bg-blue').drive(function() {
$('#test-4 span').css('color', 'green').html('success!');
});
// test 5
log_test(5, "$('#div-5.middle-size.bg-red', $('#container-right')).drive( )");
$('#div-5.middle-size.bg-red', $('#container-right')).drive(function() {
$('#test-5 span').css('color', 'green').html('success!');
});
// test 6
log_test(6, "$('#div-6.middle-size.bg-green span', $('#container-right').get(0)).drive( )");
$('#div-6.middle-size.bg-green span', $('#container-right').get(0)).drive(function() {
$('#test-6 span').css('color', 'green').html('success!');
});
// test 7
log_test(7, "$('#container-right #div-7.middle-size.bg-blue > span').drive( )");
$('#container-right #div-7.middle-size.bg-blue > span').drive(function() {
$('#test-7 span').css('color', 'green').html('success!');
});
// test 8
log_test(8, "$('#container-right #div-8.middle-size.bg-red > form > input').drive( )");
$('#container-right #div-8.middle-size.bg-red > form > input').drive(function() {
$('#test-8 span').css('color', 'green').html('success!');
});
} catch(e) {
alert(e);
}
}
$(function() {
$('#container-left form input:button').bind('click', run_tests);
});
</script>
<noscript>
Your browser must have JavaScript enabled to run the unit tests.
</noscript>
<style type="text/css">
.big-container { float: left; width: 550px; min-height: 300px; }
.bg-red { background-color: #FF0000; }
.bg-green { background-color: #00FF00; }
.bg-blue { background-color: #0000FF; }
div.middle-size { float: left; width: 100%; height: 40px; }
div.clearer { clear: both; }
span { color: red; }
</style>
</head>
<body>
<h1>Drive jQuery plugin :: unit tests</h1>
<br />
<div class="clearer"></div>
<div id="container-left" class="big-container" style="border: 1px solid">
<form>
<input type="button" value="run unit tests" />
<input type="submit" value="reload test page" />
</form>
</div>
<div id="container-right" class="big-container" style="border: 1px solid">
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.