aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2017-10-19 13:48:03 +0200
committerRobert Jaros <rjaros@finn.pl>2017-10-19 13:48:03 +0200
commitd17f27058f41f2dddd9fd5e88149ed55f9f7bf0c (patch)
treeb475544b8af881fcb5f09a6fb12c82155b060976 /src/test
parent94d1930aaf160d7271aabe97bf167a911391210b (diff)
downloadkvision-d17f27058f41f2dddd9fd5e88149ed55f9f7bf0c.tar.gz
kvision-d17f27058f41f2dddd9fd5e88149ed55f9f7bf0c.tar.bz2
kvision-d17f27058f41f2dddd9fd5e88149ed55f9f7bf0c.zip
Form control: Radio
Unit tests
Diffstat (limited to 'src/test')
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/core/KVManagerSpec.kt4
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt2
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt8
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxInputSpec.kt12
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/RadioSpec.kt32
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/html/ListSpec.kt4
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt4
7 files changed, 55 insertions, 11 deletions
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/core/KVManagerSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/core/KVManagerSpec.kt
index 9a5861df..f47e1900 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/core/KVManagerSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/core/KVManagerSpec.kt
@@ -13,7 +13,7 @@ import kotlin.test.assertTrue
class KVManagerSpec : DomSpec {
@Test
- fun patch_ById() {
+ fun patchById() {
run {
val vnode = h("span", snOpt {
attrs = snAttrs(listOf("id" to "test_new"))
@@ -26,7 +26,7 @@ class KVManagerSpec : DomSpec {
}
@Test
- fun patch_ByVnode() {
+ fun patchByVnode() {
run {
val vnode1 = h("span", snOpt {
attrs = snAttrs(listOf("id" to "test2"))
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt
index 179788d0..4e8c4ea1 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt
@@ -22,7 +22,7 @@ class WidgetSpec : WSpec {
}
@Test
- fun render_ToDom() {
+ fun renderToDom() {
runW { widget, element ->
widget.addCssClass("testClass")
widget.title = "test_title"
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 5f417f03..4e42fbe2 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
@@ -25,7 +25,7 @@ class DropDownSpec : DomSpec {
}
@Test
- fun render_DropUp() {
+ fun renderDropUp() {
run {
val root = Root("test")
val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag", dropup = true)
@@ -38,7 +38,7 @@ class DropDownSpec : DomSpec {
}
@Test
- fun render_HeaderElement() {
+ fun renderHeaderElement() {
run {
val root = Root("test")
val dd = DropDown("Dropdown", listOf("abc" to DD.HEADER.type), "flag")
@@ -51,7 +51,7 @@ class DropDownSpec : DomSpec {
}
@Test
- fun render_SeparatorElement() {
+ fun renderSeparatorElement() {
run {
val root = Root("test")
val dd = DropDown("Dropdown", listOf("abc" to DD.SEPARATOR.type), "flag")
@@ -64,7 +64,7 @@ class DropDownSpec : DomSpec {
}
@Test
- fun render_DisabledElement() {
+ fun renderDisabledElement() {
run {
val root = Root("test")
val dd = DropDown("Dropdown", listOf("abc" to DD.DISABLED.type), "flag")
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxInputSpec.kt
index 780c0337..efc6d78e 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxInputSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxInputSpec.kt
@@ -1,6 +1,7 @@
package test.pl.treksoft.kvision.form
import pl.treksoft.kvision.core.Root
+import pl.treksoft.kvision.form.CHECKINPUTTYPE
import pl.treksoft.kvision.form.CheckBoxInput
import pl.treksoft.kvision.form.TEXTINPUTTYPE
import pl.treksoft.kvision.form.TextInput
@@ -22,4 +23,15 @@ class CheckBoxInputSpec : DomSpec {
}
}
+ @Test
+ fun renderAsRadio() {
+ run {
+ val root = Root("test")
+ val ci = CheckBoxInput(type = CHECKINPUTTYPE.RADIO, value = true, 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")
+ }
+ }
+
} \ No newline at end of file
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/RadioSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/RadioSpec.kt
new file mode 100644
index 00000000..5b827a56
--- /dev/null
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/RadioSpec.kt
@@ -0,0 +1,32 @@
+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
+import kotlin.browser.document
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class RadioSpec : DomSpec {
+
+ @Test
+ 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")
+ root.add(ci)
+ val element = document.getElementById("test")
+ val id = ci.input.id
+ assertEquals("<div class=\"radio radio-danger radio-inline\"><input id=\"$id\" type=\"radio\" checked=\"\" name=\"name\" disabled=\"\" value=\"abc\"><label for=\"$id\">Label</label></div>", element?.innerHTML, "Should render correct radio button form field")
+ ci.style = RADIOSTYLE.INFO
+ ci.squared = true
+ ci.inline = false
+ assertEquals("<div class=\"checkbox checkbox-info\"><input id=\"$id\" type=\"radio\" checked=\"\" name=\"name\" disabled=\"\" value=\"abc\"><label for=\"$id\">Label</label></div>", element?.innerHTML, "Should render correct radio button form field")
+ }
+ }
+
+} \ No newline at end of file
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/ListSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/ListSpec.kt
index 78631076..48a13f6d 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/html/ListSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/html/ListSpec.kt
@@ -13,7 +13,7 @@ import kotlin.test.assertEquals
class ListSpec : DomSpec {
@Test
- fun render_Elements() {
+ fun renderElements() {
run {
val root = Root("test")
val list = ListTag(LIST.DL_HORIZ, listOf("a1", "a2", "b1", "b2"))
@@ -24,7 +24,7 @@ class ListSpec : DomSpec {
}
@Test
- fun render_AsContainer() {
+ fun renderAsContainer() {
run {
val root = Root("test")
val list = ListTag(LIST.UL)
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt
index 997714db..8d6a19d1 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt
@@ -24,7 +24,7 @@ class TagSpec : DomSpec {
}
@Test
- fun render_Rich() {
+ fun renderRich() {
run {
val root = Root("test")
val tag = Tag(TAG.H1, "This is <b>h1</b>", rich = true, align = ALIGN.RIGHT)
@@ -35,7 +35,7 @@ class TagSpec : DomSpec {
}
@Test
- fun render_AsContainer() {
+ fun renderAsContainer() {
run {
val root = Root("test")
val tag = Tag(TAG.P, align = ALIGN.RIGHT)