Skip to content
This repository
tag: v1.2.1
Fetching contributors…

Cannot retrieve contributors at this time

file 136 lines (108 sloc) 3.989 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
<!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>
Something went wrong with that request. Please try again.