1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

79 lines
2.5 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>QUnit for 'jws.js' IntDate class methods</title>
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="qunit.js"></script>
<script language="JavaScript" type="text/javascript" src="../ext/json-sans-eval.js"></script>
<script language="JavaScript" type="text/javascript" src="../jws-3.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
test("abs(new Date() - getNow()) < 3", function() {
expect(1);
var tNow1 = KJUR.jws.IntDate.getNow();
var tNow2 = ~~(new Date() / 1000);
var delta = Math.abs(tNow2 - tNow1);
equal(delta < 3, true, "");
});
test("abs(new Date() - get('now') < 3", function() {
expect(1);
var tNow1 = KJUR.jws.IntDate.get('now');
var tNow2 = ~~(new Date() / 1000);
var delta = Math.abs(tNow2 - tNow1);
equal(delta < 3, true, "");
});
test("60*60-3 < get('now + 1hour') - get('now') < 60*60+3", function() {
expect(2);
var tNow1 = KJUR.jws.IntDate.get('now');
var tNow2 = KJUR.jws.IntDate.get('now + 1hour');
var delta = tNow2 - tNow1
equal(delta < 60 * 60 + 3, true, "");
equal(delta > 60 * 60 - 3, true, "");
});
test("getZulu(20130828042500Z) = 1377663900", function() {
equal(KJUR.jws.IntDate.getZulu('20130828042500Z'), 1377663900, "");
});
test("getZulu(130828042500Z) = 1377663900", function() {
equal(KJUR.jws.IntDate.getZulu('130828042500Z'), 1377663900, "");
});
test("getZulu(19700101000000Z)", function() {
equal(KJUR.jws.IntDate.getZulu('19700101000000Z'), 0, "1");
});
test("getZulu(700101000000Z)", function() {
equal(KJUR.jws.IntDate.getZulu('700101000000Z'), 0, "1");
});
test("intDate2UTCString(getZulu(19700201000000Z))=Thu, 01 Jan 1970 00:00:00 GMT", function() {
equal(KJUR.jws.IntDate.intDate2UTCString(KJUR.jws.IntDate.getZulu('19700101000000Z')), "Thu, 01 Jan 1970 00:00:00 GMT", "1");
});
test("intDate2Zulu(0)==19700101000000Z", function() {
equal(KJUR.jws.IntDate.intDate2Zulu(0), "19700101000000Z", "1");
});
});
</script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">test markup</div>
<a href="index.html">TEST INDEX</a> |
<a href="qunit-do-jws-sign.html">sign/verify</a> |
<a href="qunit-do-jws-sign-slow.html">sign/verify slow</a> |
<a href="qunit-do-jws-intdate.html">IntDate</a> |
</body>
</html>