Created
February 13, 2013 16:15
-
-
Save gustinmi/4945710 to your computer and use it in GitHub Desktop.
Simple JavaScript UnitTester.No frameworks. Very simple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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