aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt14
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxSpec.kt9
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/CheckInputSpec.kt12
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/PasswordSpec.kt9
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/RadioSpec.kt10
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/TextAreaInputSpec.kt9
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/TextAreaSpec.kt8
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/TextInputSpec.kt9
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/TextSpec.kt8
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt6
10 files changed, 64 insertions, 30 deletions
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
index 4e42fbe2..6cfd948a 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
@@ -20,7 +20,7 @@ class DropDownSpec : DomSpec {
dd.toggle()
val element = document.getElementById("test")
val id = dd.button.id
- assertEquals("<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li><a href=\"#!/x\">abc</a></li><li><a href=\"#!/y\">def</a></li></ul></div>", element?.innerHTML, "Should render correct drop down")
+ assertEquals("<div class=\"dropdown\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\"><li><a href=\"#!/x\">abc</a></li><li><a href=\"#!/y\">def</a></li></ul></div>", element?.innerHTML, "Should render correct drop down")
}
}
@@ -28,12 +28,12 @@ class DropDownSpec : DomSpec {
fun renderDropUp() {
run {
val root = Root("test")
- val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag", dropup = true)
+ val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag").apply { dropup = true }
root.add(dd)
dd.toggle()
val element = document.getElementById("test")
val id = dd.button.id
- assertEquals("<div class=\"dropup open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li><a href=\"#!/x\">abc</a></li><li><a href=\"#!/y\">def</a></li></ul></div>", element?.innerHTML, "Should render correct drop down")
+ assertEquals("<div class=\"dropup\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\"><li><a href=\"#!/x\">abc</a></li><li><a href=\"#!/y\">def</a></li></ul></div>", element?.innerHTML, "Should render correct drop down")
}
}
@@ -46,7 +46,7 @@ class DropDownSpec : DomSpec {
dd.toggle()
val element = document.getElementById("test")
val id = dd.button.id
- assertEquals("<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li class=\"dropdown-header\">abc</li></ul></div>", element?.innerHTML, "Should render correct drop down")
+ assertEquals("<div class=\"dropdown\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\"><li class=\"dropdown-header\">abc</li></ul></div>", element?.innerHTML, "Should render correct drop down")
}
}
@@ -59,7 +59,7 @@ class DropDownSpec : DomSpec {
dd.toggle()
val element = document.getElementById("test")
val id = dd.button.id
- assertEquals("<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li class=\"divider\" role=\"separator\">abc</li></ul></div>", element?.innerHTML, "Should render correct drop down")
+ assertEquals("<div class=\"dropdown\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\"><li class=\"divider\" role=\"separator\">abc</li></ul></div>", element?.innerHTML, "Should render correct drop down")
}
}
@@ -72,7 +72,7 @@ class DropDownSpec : DomSpec {
dd.toggle()
val element = document.getElementById("test")
val id = dd.button.id
- assertEquals("<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li class=\"disabled\"><a href=\"#\">abc</a></li></ul></div>", element?.innerHTML, "Should render correct drop down")
+ assertEquals("<div class=\"dropdown\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\"><li class=\"disabled\"><a href=\"#\">abc</a></li></ul></div>", element?.innerHTML, "Should render correct drop down")
}
}
@@ -85,8 +85,6 @@ class DropDownSpec : DomSpec {
val menu = dd.list.getElementJQuery()
assertTrue("Dropdown menu is not rendered before toggle") { menu == null }
dd.toggle()
- val classes = dd.getElementJQuery()?.attr("class")
- assertTrue("Dropdown is visible after toggle") { classes?.contains("open") == true }
val menu2 = dd.list.getElementJQuery()
assertTrue("Dropdown menu is rendered after toggle") { menu2 != null }
}
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxSpec.kt
index 3da204b3..dd46d747 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxSpec.kt
@@ -14,8 +14,13 @@ class CheckBoxSpec : DomSpec {
fun render() {
run {
val root = Root("test")
- val ci = CheckBox(value = true, name = "name", style = CHECKBOXSTYLE.DANGER, disabled = true, circled = true,
- inline = true, label = "Label")
+ val ci = CheckBox(value = true, label = "Label").apply {
+ name = "name"
+ style = CHECKBOXSTYLE.DANGER
+ disabled = true
+ circled = true
+ inline = true
+ }
root.add(ci)
val element = document.getElementById("test")
val id = ci.input.id
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/CheckInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/CheckInputSpec.kt
index 8991b710..fb1b0fbf 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/form/CheckInputSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/CheckInputSpec.kt
@@ -14,7 +14,11 @@ class CheckInputSpec : DomSpec {
fun render() {
run {
val root = Root("test")
- val ci = CheckInput(value = true, name = "name", id = "idti", disabled = true)
+ val ci = CheckInput(value = true).apply {
+ name = "name"
+ id = "idti"
+ disabled = true
+ }
root.add(ci)
val element = document.getElementById("test")
assertEquals("<input id=\"idti\" type=\"checkbox\" checked=\"\" name=\"name\" disabled=\"\">", element?.innerHTML, "Should render correct checkbox field")
@@ -25,7 +29,11 @@ class CheckInputSpec : DomSpec {
fun renderAsRadio() {
run {
val root = Root("test")
- val ci = CheckInput(type = CHECKINPUTTYPE.RADIO, value = true, name = "name", id = "idti", extraValue = "abc")
+ val ci = CheckInput(type = CHECKINPUTTYPE.RADIO, value = true).apply {
+ name = "name"
+ id = "idti"
+ extraValue = "abc"
+ }
root.add(ci)
val element = document.getElementById("test")
assertEquals("<input id=\"idti\" type=\"radio\" checked=\"\" name=\"name\" value=\"abc\">", element?.innerHTML, "Should render correct radio button field")
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/PasswordSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/PasswordSpec.kt
index b03112a7..789d13fa 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/form/PasswordSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/PasswordSpec.kt
@@ -2,7 +2,6 @@ package test.pl.treksoft.kvision.form
import pl.treksoft.kvision.core.Root
import pl.treksoft.kvision.form.Password
-import pl.treksoft.kvision.form.Text
import test.pl.treksoft.kvision.DomSpec
import kotlin.browser.document
import kotlin.test.Test
@@ -14,8 +13,12 @@ class PasswordSpec : DomSpec {
fun render() {
run {
val root = Root("test")
- val ti = Password(placeholder = "place", value = "abc", name = "name",
- maxlength = 15, disabled = true, label = "Label")
+ val ti = Password(value = "abc", label = "Label").apply {
+ placeholder = "place"
+ name = "name"
+ maxlength = 15
+ disabled = true
+ }
root.add(ti)
val element = document.getElementById("test")
val id = ti.input.id
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/RadioSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/RadioSpec.kt
index 5b827a56..a0e4b853 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/form/RadioSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/RadioSpec.kt
@@ -1,8 +1,6 @@
package test.pl.treksoft.kvision.form
import pl.treksoft.kvision.core.Root
-import pl.treksoft.kvision.form.CHECKBOXSTYLE
-import pl.treksoft.kvision.form.CheckBox
import pl.treksoft.kvision.form.RADIOSTYLE
import pl.treksoft.kvision.form.Radio
import test.pl.treksoft.kvision.DomSpec
@@ -16,8 +14,12 @@ class RadioSpec : DomSpec {
fun render() {
run {
val root = Root("test")
- val ci = Radio(value = true, name = "name", style = RADIOSTYLE.DANGER, disabled = true,
- inline = true, label = "Label", extraValue = "abc")
+ val ci = Radio(value = true, label = "Label", extraValue = "abc").apply {
+ name = "name"
+ style = RADIOSTYLE.DANGER
+ disabled = true
+ inline = true
+ }
root.add(ci)
val element = document.getElementById("test")
val id = ci.input.id
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/TextAreaInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/TextAreaInputSpec.kt
index 630a0eed..ff73b35c 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/form/TextAreaInputSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/TextAreaInputSpec.kt
@@ -13,8 +13,13 @@ class TextAreaInputSpec : DomSpec {
fun render() {
run {
val root = Root("test")
- val ti = TextAreaInput(cols = 5, rows = 2, placeholder = "place", value = "abc", name = "name",
- maxlength = 15, id = "idti", disabled = true)
+ val ti = TextAreaInput(cols = 5, rows = 2, value = "abc").apply {
+ placeholder = "place"
+ name = "name"
+ maxlength = 15
+ id = "idti"
+ disabled = true
+ }
root.add(ti)
val element = document.getElementById("test")
assertEquals("<textarea class=\"form-control\" id=\"idti\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"\" cols=\"5\" rows=\"2\">abc</textarea>", element?.innerHTML, "Should render correct input field")
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/TextAreaSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/TextAreaSpec.kt
index e422ac2b..3be42379 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/form/TextAreaSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/TextAreaSpec.kt
@@ -13,8 +13,12 @@ class TextAreaSpec : DomSpec {
fun render() {
run {
val root = Root("test")
- val ti = TextArea(cols = 5, rows = 2, placeholder = "place", value = "abc", name = "name",
- maxlength = 15, disabled = true, label = "Label")
+ val ti = TextArea(cols = 5, rows = 2, value = "abc", label = "Label").apply {
+ placeholder = "place"
+ name = "name"
+ maxlength = 15
+ disabled = true
+ }
root.add(ti)
val element = document.getElementById("test")
val id = ti.input.id
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/TextInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/TextInputSpec.kt
index 9e5ed64d..0bce8656 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/form/TextInputSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/TextInputSpec.kt
@@ -14,8 +14,13 @@ class TextInputSpec : DomSpec {
fun render() {
run {
val root = Root("test")
- val ti = TextInput(type = TEXTINPUTTYPE.PASSWORD, placeholder = "place", value = "abc", name = "name",
- maxlength = 15, id = "idti", disabled = true)
+ val ti = TextInput(type = TEXTINPUTTYPE.PASSWORD, value = "abc").apply {
+ placeholder = "place"
+ name = "name"
+ maxlength = 15
+ id = "idti"
+ disabled = true
+ }
root.add(ti)
val element = document.getElementById("test")
assertEquals("<input class=\"form-control\" id=\"idti\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"\" type=\"password\" value=\"abc\">", element?.innerHTML, "Should render correct input field")
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/TextSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/TextSpec.kt
index 675d9db8..8b460e3c 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/form/TextSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/TextSpec.kt
@@ -13,8 +13,12 @@ class TextSpec : DomSpec {
fun render() {
run {
val root = Root("test")
- val ti = Text(placeholder = "place", value = "abc", name = "name",
- maxlength = 15, disabled = true, label = "Label")
+ val ti = Text(value = "abc", label = "Label").apply {
+ placeholder = "place"
+ name = "name"
+ maxlength = 15
+ disabled = true
+ }
root.add(ti)
val element = document.getElementById("test")
val id = ti.input.id
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 5ea10c7a..1190bc1a 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt
@@ -1,6 +1,6 @@
package test.pl.treksoft.kvision.utils
-import pl.treksoft.kvision.utils.Utils
+import pl.treksoft.kvision.utils.toHexString
import test.pl.treksoft.kvision.SimpleSpec
import kotlin.test.Test
import kotlin.test.assertEquals
@@ -10,9 +10,9 @@ class UtilsSpec : SimpleSpec {
@Test
fun intToHexString() {
run {
- val res = Utils.intToHexString(0xabcdef)
+ val res = 0xabcdef.toHexString()
assertEquals("abcdef", res, "Should convert int value to hex string")
- val res2 = Utils.intToHexString(0x123456)
+ val res2 = 0x123456.toHexString()
assertEquals("123456", res2, "Should convert int value to hex string")
}
}