This repository was archived by the owner on Feb 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTime_test.html
95 lines (81 loc) · 2.23 KB
/
Time_test.html
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html>
<!--
Copyright 2006 The Closure Library Authors. All Rights Reserved.
Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Prestans Unit Tests - prestans.types.Time</title>
<script src="../../closure-library/closure/goog/base.js"></script>
<script src="../deps.js"></script>
<script>
goog.require('prestans.types.Time');
goog.require('goog.testing.jsunit');
goog.require('goog.date.DateTime');
</script>
</head>
<body>
<script>
function testConstructor() {
//pass datetime
var time1_ = new prestans.types.Time({
value: new goog.date.DateTime(2014, 1, 1, 10, 0, 0)
});
assertTrue(time1_.getValue() instanceof goog.date.DateTime);
assertEquals("10:00:00", time1_.getJSONObject());
//pass string
var time2_ = new prestans.types.Time({
value: "10:30:15"
});
assertTrue(time2_.getValue() instanceof goog.date.DateTime);
assertEquals("10:30:15", time2_.getJSONObject());
}
function testGetAndSetValue() {
//test set date
var time1_ = new prestans.types.Time();
var dt_ = new goog.date.DateTime();
assertTrue(time1_.setValue(dt_));
assertEquals(dt_, time1_.getValue());
//test set string
var time2_ = new prestans.types.Time();
var s_ = "13:30:00";
assertTrue(time2_.setValue(s_));
assertEquals("13:30:00", time2_.getJSONObject());
}
function testRequired() {
var date1_ = new prestans.types.Time({
required: false
});
assertTrue(date1_.setValue(null));
var date2_ = new prestans.types.Time({
required: true
});
assertFalse(date2_.setValue(null));
}
function testDefault() {
//Test now constant
var t1_ = new prestans.types.Time({
required: false,
defaultValue: prestans.types.Time.NOW
});
assertTrue(t1_.getValue() instanceof goog.date.DateTime);
//Test date object
var datetime_ = new goog.date.DateTime();
var t2_ = new prestans.types.Time({
required: false,
defaultValue: datetime_
});
assertEquals(datetime_, t2_.getValue());
//Test ISO string format
var s_ = "2010-01-01 10:00:00";
var t3_ = new prestans.types.Time({
required: false,
defaultValue: s_
});
assertEquals("10:00:00", t3_.getJSONObject());
}
</script>
</body>
</html>