QUnit example
A simple example of QUnit tests using JSFiddle
HTML
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css">
<script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
JavaScript
var createFoo = function() {
var foo = {},
fn = function() {
var i = 0;
this.increment = function() {
i++;
};
this.get = function() {
return i;
};
};
foo = fn.apply(foo, arguments) || foo;
return foo;
},
foo = createFoo();
test('foo test', function () {
foo.increment();
equal(foo.get(), 1, 'pass');
});
var createBar = function() {
var bar = {},
fn = function() {
var i = 0;
this.increment = function() {
i++;
};
this.get = function() {
return i;
};
};
bar = fn.apply(bar, arguments);
return bar;
},
bar = createBar();
test('bar tests', function () {
bar.increment();
});