JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.2.5/mocha.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.2.5/mocha.min.js"></script>
<script src="https://rawgit.com/gampleman/quick_check.js/master/dist/jasmine-quick-check.js"></script>
<div id="mocha"></div>
JavaScript
mocha.setup('bdd'); //tell mocha which interface you are using
function sort(list) {
for (var j = 1; j < list.length; j++) {
var key = list[j],
i = j - 1;
while (i >= 0 && list[i] > key) {
list[i + 1] = list[i];
i--;
}
list[i + 1] = key;
}
return list;
}
describe('sort', function () { //describe unit of code to test
it('array is same length', function() {
qc.forAll(qc.arrayOf(qc.int), function(list) {
var orig = list.slice(),
sorted = sort(list);
if (orig.length !== sorted.length) {
throw "Sort failed on example " + JSON.stringify(orig);
}
});
});
});
mocha.run();