diff options
Diffstat (limited to 'src/test/kotlin')
8 files changed, 166 insertions, 6 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 8f327928..5f417f03 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt @@ -19,7 +19,8 @@ class DropDownSpec : DomSpec { root.add(dd) dd.toggle() val element = document.getElementById("test") - assertEquals("<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"kv_dropdown_0\" 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=\"kv_dropdown_0\" 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") + 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") } } @@ -31,7 +32,8 @@ class DropDownSpec : DomSpec { root.add(dd) dd.toggle() val element = document.getElementById("test") - assertEquals("<div class=\"dropup open\"><button class=\"dropdown btn btn-default\" id=\"kv_dropdown_1\" 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=\"kv_dropdown_1\" 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") + 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") } } @@ -43,7 +45,8 @@ class DropDownSpec : DomSpec { root.add(dd) dd.toggle() val element = document.getElementById("test") - assertEquals("<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"kv_dropdown_2\" 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=\"kv_dropdown_2\" aria-expanded=\"true\"><li class=\"dropdown-header\">abc</li></ul></div>", element?.innerHTML, "Should render correct drop down") + 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") } } @@ -55,7 +58,8 @@ class DropDownSpec : DomSpec { root.add(dd) dd.toggle() val element = document.getElementById("test") - assertEquals("<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"kv_dropdown_3\" 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=\"kv_dropdown_3\" aria-expanded=\"true\"><li class=\"divider\" role=\"separator\">abc</li></ul></div>", element?.innerHTML, "Should render correct drop down") + 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") } } @@ -67,7 +71,8 @@ class DropDownSpec : DomSpec { root.add(dd) dd.toggle() val element = document.getElementById("test") - assertEquals("<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"kv_dropdown_4\" 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=\"kv_dropdown_4\" aria-expanded=\"true\"><li class=\"disabled\"><a href=\"#\">abc</a></li></ul></div>", element?.innerHTML, "Should render correct drop down") + 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") } } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxInputSpec.kt new file mode 100644 index 00000000..780c0337 --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxInputSpec.kt @@ -0,0 +1,25 @@ +package test.pl.treksoft.kvision.form + +import pl.treksoft.kvision.core.Root +import pl.treksoft.kvision.form.CheckBoxInput +import pl.treksoft.kvision.form.TEXTINPUTTYPE +import pl.treksoft.kvision.form.TextInput +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test +import kotlin.test.assertEquals + +class CheckBoxInputSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test") + val ci = CheckBoxInput(value = true, 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") + } + } + +}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxSpec.kt new file mode 100644 index 00000000..3da204b3 --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/CheckBoxSpec.kt @@ -0,0 +1,30 @@ +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 test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test +import kotlin.test.assertEquals + +class CheckBoxSpec : DomSpec { + + @Test + 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") + root.add(ci) + val element = document.getElementById("test") + val id = ci.input.id + assertEquals("<div class=\"checkbox checkbox-danger checkbox-circle checkbox-inline\"><input class=\"styled\" id=\"$id\" type=\"checkbox\" checked=\"\" name=\"name\" disabled=\"\"><label for=\"$id\">Label</label></div>", element?.innerHTML, "Should render correct checkbox form field") + ci.style = CHECKBOXSTYLE.INFO + ci.circled = false + ci.inline = false + assertEquals("<div class=\"checkbox checkbox-info\"><input class=\"styled\" id=\"$id\" type=\"checkbox\" checked=\"\" name=\"name\" disabled=\"\"><label for=\"$id\">Label</label></div>", element?.innerHTML, "Should render correct checkbox form field") + } + } + +}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/FieldLabelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/FieldLabelSpec.kt new file mode 100644 index 00000000..3cca28cf --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/FieldLabelSpec.kt @@ -0,0 +1,23 @@ +package test.pl.treksoft.kvision.form + +import pl.treksoft.kvision.core.Root +import pl.treksoft.kvision.form.FieldLabel +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test +import kotlin.test.assertEquals + +class FieldLabelSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test") + val fl = FieldLabel("input", "Label") + root.add(fl) + val element = document.getElementById("test") + assertEquals("<label for=\"input\">Label</label>", element?.innerHTML, "Should render correct label") + } + } + +}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/PasswordSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/PasswordSpec.kt new file mode 100644 index 00000000..4563da03 --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/PasswordSpec.kt @@ -0,0 +1,26 @@ +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 +import kotlin.test.assertEquals + +class PasswordSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test") + val ti = Password(placeholder = "place", value = "abc", name = "name", + maxlength = 15, disabled = true, label = "Label") + root.add(ti) + val element = document.getElementById("test") + val id = ti.input.id + assertEquals("<div class=\"form-group\"><label for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" type=\"password\" placeholder=\"place\" value=\"abc\" name=\"name\" maxlength=\"15\" disabled=\"\"></div>", element?.innerHTML, "Should render correct input form field") + } + } + +}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/TextInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/TextInputSpec.kt new file mode 100644 index 00000000..55325436 --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/TextInputSpec.kt @@ -0,0 +1,25 @@ +package test.pl.treksoft.kvision.form + +import pl.treksoft.kvision.core.Root +import pl.treksoft.kvision.form.TEXTINPUTTYPE +import pl.treksoft.kvision.form.TextInput +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test +import kotlin.test.assertEquals + +class TextInputSpec : DomSpec { + + @Test + 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) + root.add(ti) + val element = document.getElementById("test") + assertEquals("<input class=\"form-control\" id=\"idti\" type=\"password\" placeholder=\"place\" value=\"abc\" name=\"name\" maxlength=\"15\" disabled=\"\">", element?.innerHTML, "Should render correct input field") + } + } + +}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/TextSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/TextSpec.kt new file mode 100644 index 00000000..5e378d55 --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/TextSpec.kt @@ -0,0 +1,25 @@ +package test.pl.treksoft.kvision.form + +import pl.treksoft.kvision.core.Root +import pl.treksoft.kvision.form.Text +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test +import kotlin.test.assertEquals + +class TextSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test") + val ti = Text(placeholder = "place", value = "abc", name = "name", + maxlength = 15, disabled = true, label = "Label") + root.add(ti) + val element = document.getElementById("test") + val id = ti.input.id + assertEquals("<div class=\"form-group\"><label for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" type=\"text\" placeholder=\"place\" value=\"abc\" name=\"name\" maxlength=\"15\" disabled=\"\"></div>", element?.innerHTML, "Should render correct input form field") + } + } + +}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/SplitPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/SplitPanelSpec.kt index 6e6ede53..e3442f59 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/SplitPanelSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/panel/SplitPanelSpec.kt @@ -26,7 +26,8 @@ class SplitPanelSpec : DomSpec { splitPanel.add(label1) splitPanel.add(label2) val element = document.getElementById("test") - assertEquals("<div class=\"splitpanel-vertical\"><span class=\"resizable\">abc</span><div class=\"splitter-vertical\" id=\"kv_splitter_0\" style=\"touch-action: none;\"></div><span>def</span></div>", element?.innerHTML, "Should render correct split panel") + val id = splitPanel.splitter.id + assertEquals("<div class=\"splitpanel-vertical\"><span class=\"resizable\">abc</span><div class=\"splitter-vertical\" id=\"$id\" style=\"touch-action: none;\"></div><span>def</span></div>", element?.innerHTML, "Should render correct split panel") } } }
\ No newline at end of file |