-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
54 lines (37 loc) · 1.84 KB
/
test.html
File metadata and controls
54 lines (37 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html>
<head>
<title>ethernity unit test</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.3.2.css">
<script type="application/javascript" src="https://code.jquery.com/qunit/qunit-2.3.2.js"></script>
<script type="application/javascript" src="./ethernity.deploy.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script type="application/javascript">
QUnit.test( "ethernity unit test", function( assert ) {
const Ethernity = ethernity;
let sample1 = new Date( "8/15/2016 12:47:45 PM" );
assert.equal( Ethernity( sample1 ).printTime( ), "August 15, 2016 | 12:47:45 PM",
"should be equal to 'August 15, 2016 | 12:47:45 PM'" );
assert.equal( Ethernity( sample1 ).getTime( ), "12:47:45 PM",
"should be equal to '12:47:45 PM'" );
assert.equal( Ethernity( sample1 ).getDate( ), "August 15, 2016",
"should be equal to August 15, 2016" );
assert.equal( Ethernity( sample1 ).realTime( ), "2016-08-15T04:47:45",
"should be equal to 2016-08-15T04:47:45" );
assert.equal( Ethernity( sample1 ).relativeTime( ), "2016-08-15T12:47:45",
"should be equal to '2016-08-15T12:47:45'" );
let ethernity_time = Ethernity( sample1 ).trueTime;
assert.equal( ethernity_time, "02016081504474500480", "should be equal to 02016081504474500480" );
let compact1 = Ethernity( sample1 ).compact( );
assert.deepEqual( compact1, [ 20160815044745, 480 ], "should be equal to [ 20160815044745, 480 ]" );
let comparison1 = Ethernity( ethernity_time ).parse( );
let comparison2 = Ethernity( compact1 ).parse( );
assert.deepEqual( comparison1.trueTime, comparison2.trueTime,
"should have the same trueTime regardless of how many times it was parse" );
} );
</script>
</body>
</html>