QUnit Lab
by ramyaaviji
HTML
<script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css">
<h1 id="qunit-header">Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
<ul>
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ul>
</div>
JavaScript
/*!
* jQuery Enumerate - v1.0 - 1/2/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($){
$.fn.enumerate = function(start) {
if (typeof start !== "number") {
start = 1;
}
return this.each(function(i) {
$(this).prepend((start + i) + ". ");
});
};
}(jQuery));
test("li test", 1, function() {
var fixture = $( "#qunit-fixture ul" );
console.log(fixture.enumerate());
equal(fixture.enumerate(), fixture, "li should have 3");
});
test("0 passed", 3, function() {
var items = $("#qunit-fixture li").enumerate(0);
equal(items.eq(0).text(), "0. foo", "first item should have index 0");
equal(items.eq(1).text(), "1. bar", "second item should have index 1");
equal(items.eq(2).text(), "2. baz", "third item should have index 2");
});