aboutsummaryrefslogtreecommitdiff
path: root/src/test/kotlin
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2017-11-12 03:26:57 +0100
committerRobert Jaros <rjaros@finn.pl>2017-11-12 03:26:57 +0100
commitc5c29491437f1b9de2ab6bff05a1455b42edfcfc (patch)
treeb9d20472a9427d1bf8d8880c52e206333ca94513 /src/test/kotlin
parenta4343ed3c4021db99de0fbc3f7c76929ad758265 (diff)
downloadkvision-c5c29491437f1b9de2ab6bff05a1455b42edfcfc.tar.gz
kvision-c5c29491437f1b9de2ab6bff05a1455b42edfcfc.tar.bz2
kvision-c5c29491437f1b9de2ab6bff05a1455b42edfcfc.zip
DateTimePicker components
Diffstat (limited to 'src/test/kotlin')
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt
index 1190bc1a..3157affc 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt
@@ -1,7 +1,10 @@
package test.pl.treksoft.kvision.utils
+import pl.treksoft.kvision.utils.toDateF
import pl.treksoft.kvision.utils.toHexString
+import pl.treksoft.kvision.utils.toStringF
import test.pl.treksoft.kvision.SimpleSpec
+import kotlin.js.Date
import kotlin.test.Test
import kotlin.test.assertEquals
@@ -16,4 +19,32 @@ class UtilsSpec : SimpleSpec {
assertEquals("123456", res2, "Should convert int value to hex string")
}
}
-} \ No newline at end of file
+
+ @Test
+ fun toDateF() {
+ run {
+ val res = "2017-03-14 14:50:35".toDateF()
+ assertEquals(js("new Date(2017,2,14,14,50,35).getTime()"), res.getTime(), "Should convert String value to Date")
+ }
+ }
+
+ @Test
+ fun toStringF() {
+ run {
+ val date = js("new Date()")
+ val res = Date().toStringF()
+ val y = date.getFullYear()
+ val m = date.getMonth() + 1
+ val m2 = if (m<10) "0$m" else "$m"
+ val d = date.getDate()
+ val d2 = if (d<10) "0$d" else "$d"
+ val h = date.getHours()
+ val h2 = if (h<10) "0$h" else "$h"
+ val min = date.getMinutes()
+ val min2 = if (min<10) "0$min" else "$min"
+ val sec = date.getSeconds()
+ val sec2 = if (sec<10) "0$sec" else "$sec"
+ assertEquals("$y-$m2-$d2 $h2:$min2:$sec2", res, "Should convert Date value to String")
+ }
+ }
+}