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/table/CellSpec.kt25
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/table/HeaderCellSpec.kt29
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/table/RowSpec.kt28
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/table/TableSpec.kt46
4 files changed, 128 insertions, 0 deletions
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/table/CellSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/table/CellSpec.kt
new file mode 100644
index 00000000..7f39f133
--- /dev/null
+++ b/src/test/kotlin/test/pl/treksoft/kvision/table/CellSpec.kt
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2018. Robert Jaros
+ */
+package test.pl.treksoft.kvision.table
+
+import pl.treksoft.kvision.panel.Root
+import pl.treksoft.kvision.table.Cell
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class CellSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test")
+ val cell = Cell("This is a cell")
+ root.add(cell)
+ val element = document.getElementById("test")
+ assertEqualsHtml("<td>This is a cell</td>", element?.innerHTML, "Should render correct table cell")
+ }
+ }
+
+}
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/table/HeaderCellSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/table/HeaderCellSpec.kt
new file mode 100644
index 00000000..ef417fc8
--- /dev/null
+++ b/src/test/kotlin/test/pl/treksoft/kvision/table/HeaderCellSpec.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2018. Robert Jaros
+ */
+package test.pl.treksoft.kvision.table
+
+import pl.treksoft.kvision.panel.Root
+import pl.treksoft.kvision.table.HeaderCell
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class HeaderCellSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test")
+ val cell = HeaderCell("This is a header cell")
+ root.add(cell)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<th>This is a header cell</th>",
+ element?.innerHTML,
+ "Should render correct table header cell"
+ )
+ }
+ }
+
+}
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/table/RowSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/table/RowSpec.kt
new file mode 100644
index 00000000..04cd5a2d
--- /dev/null
+++ b/src/test/kotlin/test/pl/treksoft/kvision/table/RowSpec.kt
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2018. Robert Jaros
+ */
+package test.pl.treksoft.kvision.table
+
+import pl.treksoft.kvision.panel.Root
+import pl.treksoft.kvision.table.Cell.Companion.cell
+import pl.treksoft.kvision.table.Row
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class RowSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test")
+ val row = Row {
+ cell("A")
+ }
+ root.add(row)
+ val element = document.getElementById("test")
+ assertEqualsHtml("<tr><td>A</td></tr>", element?.innerHTML, "Should render correct table row")
+ }
+ }
+
+}
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/table/TableSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/table/TableSpec.kt
new file mode 100644
index 00000000..b544a346
--- /dev/null
+++ b/src/test/kotlin/test/pl/treksoft/kvision/table/TableSpec.kt
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2018. Robert Jaros
+ */
+package test.pl.treksoft.kvision.table
+
+import pl.treksoft.kvision.panel.Root
+import pl.treksoft.kvision.table.Cell.Companion.cell
+import pl.treksoft.kvision.table.Row.Companion.row
+import pl.treksoft.kvision.table.Table
+import pl.treksoft.kvision.table.TableType
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class TableSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test")
+ val table = Table(listOf("a", "b")) {
+ row {
+ cell("A")
+ cell("B")
+ }
+ }
+ root.add(table)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<table class=\"table\"><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>A</td><td>B</td></tr></tbody></table>",
+ element?.innerHTML,
+ "Should render correct table"
+ )
+ table.caption = "Caption"
+ table.responsive = true
+ table.types = setOf(TableType.BORDERED)
+ val element2 = document.getElementById("test")
+ assertEqualsHtml(
+ "<div class=\"table-responsive\"><table class=\"table table-bordered\"><caption>Caption</caption><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>A</td><td>B</td></tr></tbody></table></div>",
+ element2?.innerHTML,
+ "Should render correct responsive table"
+ )
+ }
+ }
+
+}