Skip to content

Instantly share code, notes, and snippets.

@gustinmi
Created February 13, 2013 16:15
Show Gist options
  • Save gustinmi/4945710 to your computer and use it in GitHub Desktop.
Save gustinmi/4945710 to your computer and use it in GitHub Desktop.
Simple JavaScript UnitTester.No frameworks. Very simple
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Tests </title>
<style type="text/css">
div.results b {
color: green;
}
div.results b[class='err'] {
color: red;
}
</style>
</head>
<body>
<h1>Test results</h1>
<div class="results">
</div>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="js/storage.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
var out = ['<table><thead><th>Name</th></thead><tbody>'],
tests = [
{
"test" : function(){
var myObj = [1,2,3,4,5];
window.AppHtml5.storage.save("k1",myObj);
var testObj = window.AppHtml5.storage.load("k1");
return (
(myObj.length == testObj.length) && (myObj[0] == testObj[0]) ? "storage <b>ok</b>" : "storage <b class=\"err\">not ok</b>"
);
}
},
{
"test" : function(){
return "something <b class=\"err\">not ok</b>" ;
}
}
];
for (var i=0; i<tests.length; i++){
out.push('<tr><td>')
out.push(tests[i]['test']());
out.push('</td></tr>')
}
out.push('</tbody></table>');
$('body div.results').html(out.join(""));
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment