aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-01-16 15:12:55 +0100
committerRobert Jaros <rjaros@finn.pl>2018-01-16 15:12:55 +0100
commit2c4fe2ef6fd0a0bfa53f6496a1d4bede8fe9219d (patch)
tree93cfb31ba0749828ebb6805438c80a985ba8995c /src/test
parentbcc5292dd95e5824da41a19bfbf64ebc25d79102 (diff)
downloadkvision-2c4fe2ef6fd0a0bfa53f6496a1d4bede8fe9219d.tar.gz
kvision-2c4fe2ef6fd0a0bfa53f6496a1d4bede8fe9219d.tar.bz2
kvision-2c4fe2ef6fd0a0bfa53f6496a1d4bede8fe9219d.zip
Radio button group form control
Diffstat (limited to 'src/test')
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupSpec.kt30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupSpec.kt
new file mode 100644
index 00000000..b1dc19ea
--- /dev/null
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupSpec.kt
@@ -0,0 +1,30 @@
+package test.pl.treksoft.kvision.form.check
+
+import pl.treksoft.kvision.core.Root
+import pl.treksoft.kvision.form.check.Radio
+import pl.treksoft.kvision.form.check.RadioGroup
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class RadioGroupSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test")
+ val ci = RadioGroup(options = listOf("a" to "A", "b" to "B"), value = "a", label = "Label").apply {
+ disabled = true
+ inline = true
+ }
+ root.add(ci)
+ val element = document.getElementById("test")
+ val id = ci.flabel.forId
+ val rid1 = ci.getChildren().filterIsInstance<Radio>().first().input.id
+ val rid2 = ci.getChildren().filterIsInstance<Radio>().last().input.id
+ assertEquals("<div class=\"form-group kv-radiogroup-inline\"><label class=\"control-label\" for=\"$id\">Label</label><div class=\"radio\"><input id=\"$rid1\" type=\"radio\" name=\"$id\" disabled=\"\" value=\"a\"><label for=\"$rid1\">A</label></div><div class=\"radio\"><input id=\"$rid2\" type=\"radio\" name=\"$id\" disabled=\"\" value=\"b\"><label for=\"$rid2\">B</label></div></div>", element?.innerHTML, "Should render correct radio button group form control")
+ }
+ }
+
+} \ No newline at end of file