aboutsummaryrefslogtreecommitdiff
path: root/src/test/kotlin
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-03-07 00:07:07 +0100
committerRobert Jaros <rjaros@finn.pl>2018-03-07 00:07:07 +0100
commitc87e1851919c60d57aeb77809a94f589d537f827 (patch)
tree4c1ba89595d7710711c35829baf149740e0cbf90 /src/test/kotlin
parent35a6bc496500d77a9f76fc9806713ed378cfbb68 (diff)
downloadkvision-c87e1851919c60d57aeb77809a94f589d537f827.tar.gz
kvision-c87e1851919c60d57aeb77809a94f589d537f827.tar.bz2
kvision-c87e1851919c60d57aeb77809a94f589d537f827.zip
More type-safe forms implementation.
Diffstat (limited to 'src/test/kotlin')
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/FormPanelSpec.kt28
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/FormSpec.kt28
2 files changed, 28 insertions, 28 deletions
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/FormPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/FormPanelSpec.kt
index 88695366..33b439a5 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/form/FormPanelSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/FormPanelSpec.kt
@@ -51,7 +51,7 @@ class FormPanelSpec : SimpleSpec {
val result = formPanel.getData()
assertNull(result.a, "FormPanel should return null without adding any control")
val textField = Text()
- formPanel.add("a", textField)
+ formPanel.add(DataForm::a, textField)
formPanel.setData(data)
val result2 = formPanel.getData()
assertEquals("Test value", result2.a, "FormPanel should return initial value")
@@ -71,9 +71,9 @@ class FormPanelSpec : SimpleSpec {
DataForm(it)
}
val data = DataForm(mapOf("a" to "Test value"))
- formPanel.add("a", Text())
+ formPanel.add(DataForm::a, Text())
formPanel.setData(data)
- formPanel.remove("a")
+ formPanel.remove(DataForm::a)
val result = formPanel.getData()
assertNull(result.a, "FormPanel should return null after removing control")
}
@@ -92,7 +92,7 @@ class FormPanelSpec : SimpleSpec {
DataForm(it)
}
val data = DataForm(mapOf("a" to "Test value"))
- formPanel.add("a", Text())
+ formPanel.add(DataForm::a, Text())
formPanel.setData(data)
formPanel.removeAll()
val result = formPanel.getData()
@@ -112,10 +112,10 @@ class FormPanelSpec : SimpleSpec {
val formPanel = FormPanel {
DataForm(it)
}
- formPanel.add("a", Text())
- val control = formPanel.getControl("b")
+ formPanel.add(DataForm::a, Text())
+ val control = formPanel.getControl(DataForm::b)
assertNull(control, "Should return null when there is no such control")
- val control2 = formPanel.getControl("a")
+ val control2 = formPanel.getControl(DataForm::a)
assertNotNull(control2, "Should return correct control")
}
}
@@ -133,13 +133,13 @@ class FormPanelSpec : SimpleSpec {
DataForm(it)
}
val data = DataForm(mapOf("a" to "Test value"))
- formPanel.add("a", Text())
- val b = formPanel["b"]
+ formPanel.add(DataForm::a, Text())
+ val b = formPanel[DataForm::b]
assertNull(b, "Should return null value when there is no added control")
- val a = formPanel["a"]
+ val a = formPanel[DataForm::a]
assertNull(a, "Should return null value when control is empty")
formPanel.setData(data)
- val a2 = formPanel["a"]
+ val a2 = formPanel[DataForm::a]
assertEquals("Test value", a2, "Should return correct value")
}
}
@@ -158,7 +158,7 @@ class FormPanelSpec : SimpleSpec {
}
val data = DataForm(mapOf("a" to "Test value"))
val textField = Text()
- formPanel.add("a", textField)
+ formPanel.add(DataForm::a, textField)
formPanel.setData(data)
textField.value = "New value"
val result = formPanel.getData()
@@ -177,10 +177,10 @@ class FormPanelSpec : SimpleSpec {
val formPanel = FormPanel {
DataForm(it)
}
- formPanel.add("s", Text()) {
+ formPanel.add(DataForm::s, Text()) {
it.getValue()?.length ?: 0 > 4
}
- formPanel.add("d", DateTime(), required = true)
+ formPanel.add(DataForm::d, DateTime(), required = true)
formPanel.setData(DataForm(mapOf("s" to "123")))
val valid = formPanel.validate()
assertEquals(false, valid, "Should be invalid with initial data")
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/FormSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/FormSpec.kt
index 128b96b1..ee3cd2af 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/form/FormSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/FormSpec.kt
@@ -51,7 +51,7 @@ class FormSpec : SimpleSpec {
val result = form.getData()
assertNull(result.a, "Form should return null without adding any control")
val textField = Text()
- form.add("a", textField)
+ form.add(DataForm::a, textField)
form.setData(data)
val result2 = form.getData()
assertEquals("Test value", result2.a, "Form should return initial value")
@@ -71,9 +71,9 @@ class FormSpec : SimpleSpec {
DataForm(it)
}
val data = DataForm(mapOf("a" to "Test value"))
- form.add("a", Text())
+ form.add(DataForm::a, Text())
form.setData(data)
- form.remove("a")
+ form.remove(DataForm::a)
val result = form.getData()
assertNull(result.a, "Form should return null after removing control")
}
@@ -92,7 +92,7 @@ class FormSpec : SimpleSpec {
DataForm(it)
}
val data = DataForm(mapOf("a" to "Test value"))
- form.add("a", Text())
+ form.add(DataForm::a, Text())
form.setData(data)
form.removeAll()
val result = form.getData()
@@ -112,10 +112,10 @@ class FormSpec : SimpleSpec {
val form = Form {
DataForm(it)
}
- form.add("a", Text())
- val control = form.getControl("b")
+ form.add(DataForm::a, Text())
+ val control = form.getControl(DataForm::b)
assertNull(control, "Should return null when there is no such control")
- val control2 = form.getControl("a")
+ val control2 = form.getControl(DataForm::a)
assertNotNull(control2, "Should return correct control")
}
}
@@ -133,13 +133,13 @@ class FormSpec : SimpleSpec {
DataForm(it)
}
val data = DataForm(mapOf("a" to "Test value"))
- form.add("a", Text())
- val b = form["b"]
+ form.add(DataForm::a, Text())
+ val b = form[DataForm::b]
assertNull(b, "Should return null value when there is no added control")
- val a = form["a"]
+ val a = form[DataForm::a]
assertNull(a, "Should return null value when control is empty")
form.setData(data)
- val a2 = form["a"]
+ val a2 = form[DataForm::a]
assertEquals("Test value", a2, "Should return correct value")
}
}
@@ -158,7 +158,7 @@ class FormSpec : SimpleSpec {
}
val data = DataForm(mapOf("a" to "Test value"))
val textField = Text()
- form.add("a", textField)
+ form.add(DataForm::a, textField)
form.setData(data)
textField.value = "New value"
val result = form.getData()
@@ -177,10 +177,10 @@ class FormSpec : SimpleSpec {
val form = Form {
DataForm(it)
}
- form.add("s", Text()) {
+ form.add(DataForm::s, Text()) {
it.getValue()?.length ?: 0 > 4
}
- form.add("d", DateTime(), required = true)
+ form.add(DataForm::d, DateTime(), required = true)
form.setData(DataForm(mapOf("s" to "123")))
val valid = form.validate()
assertEquals(false, valid, "Should be invalid with initial data")