aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-10-13 17:04:42 +0200
committerRobert Jaros <rjaros@finn.pl>2019-10-13 17:04:42 +0200
commit780c340a481676e27398dccf4503e8f0b9c63060 (patch)
tree65efeec54d3b4d4e420c5882db38814e40eb3940
parente84227897eac9d90e79c5ba5ae775eac1085ea64 (diff)
downloadkvision-780c340a481676e27398dccf4503e8f0b9c63060.tar.gz
kvision-780c340a481676e27398dccf4503e8f0b9c63060.tar.bz2
kvision-780c340a481676e27398dccf4503e8f0b9c63060.zip
New Application class to reduce applications boilerplate (#92).
New testutils module.
-rw-r--r--build.gradle3
-rw-r--r--kvision-modules/kvision-bootstrap-select/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt100
-rw-r--r--kvision-modules/kvision-bootstrap-spinner/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt100
-rw-r--r--kvision-modules/kvision-bootstrap-upload/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt100
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt2
-rw-r--r--kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt100
-rw-r--r--kvision-modules/kvision-datacontainer/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt100
-rw-r--r--kvision-modules/kvision-redux-kotlin/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt100
-rw-r--r--kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt100
-rw-r--r--kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt100
-rw-r--r--kvision-modules/kvision-tabulator/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt100
-rw-r--r--kvision-modules/kvision-testutils/build.gradle60
-rw-r--r--kvision-modules/kvision-testutils/src/test/kotlin/pl/treksoft/kvision/test/TestUtil.kt (renamed from kvision-modules/kvision-bootstrap-datetime/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt)4
-rw-r--r--settings.gradle3
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/Application.kt86
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/HMR.kt (renamed from src/main/kotlin/pl/treksoft/kvision/hmr/HMR.kt)2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/hmr/ApplicationBase.kt41
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/Root.kt39
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt2
19 files changed, 193 insertions, 949 deletions
diff --git a/build.gradle b/build.gradle
index da4ab01a..39321f5c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -185,7 +185,8 @@ dokka {
'kvision-modules/kvision-server-ktor/src/main/kotlin',
'kvision-modules/kvision-server-spring-boot/src/main/kotlin',
'kvision-modules/kvision-cordova/src/main/kotlin',
- 'kvision-modules/kvision-electron/src/main/kotlin')
+ 'kvision-modules/kvision-electron/src/main/kotlin',
+ 'kvision-modules/kvision-testutils/src/main/kotlin')
classpath = [new File("dokka/kvision-dokka-helper.jar")]
outputFormat = 'html'
outputDirectory = "$buildDir/kdoc"
diff --git a/kvision-modules/kvision-bootstrap-select/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-bootstrap-select/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
deleted file mode 100644
index 13c8531b..00000000
--- a/kvision-modules/kvision-bootstrap-select/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2017-present Robert Jaros
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package test.pl.treksoft.kvision
-
-import org.w3c.dom.Element
-import pl.treksoft.jquery.jQuery
-import pl.treksoft.kvision.core.Widget
-import pl.treksoft.kvision.panel.Root
-import kotlin.browser.document
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
-
-interface TestSpec {
- fun beforeTest()
-
- fun afterTest()
-
- fun run(code: () -> Unit) {
- beforeTest()
- code()
- afterTest()
- }
-}
-
-interface SimpleSpec : TestSpec {
-
- override fun beforeTest() {
- }
-
- override fun afterTest() {
- }
-
-}
-
-interface DomSpec : TestSpec {
-
- override fun beforeTest() {
- val fixture = "<div style=\"display: none\" id=\"pretest\">" +
- "<div id=\"test\"></div></div>"
- document.body?.insertAdjacentHTML("afterbegin", fixture)
- }
-
- override fun afterTest() {
- val div = document.getElementById("pretest")
- div?.let { jQuery(it).remove() }
- jQuery(".modal-backdrop").remove()
- Root.shutdown()
- }
-
- fun assertEqualsHtml(expected: String?, actual: String?, message: String?) {
- if (expected != null && actual != null) {
- val exp = jQuery(expected)
- val act = jQuery(actual)
- val result = exp[0]?.isEqualNode(act[0])
- if (result == true) {
- assertTrue(result == true, message)
- } else {
- assertEquals(expected, actual, message)
- }
- } else {
- assertEquals(expected, actual, message)
- }
- }
-}
-
-interface WSpec : DomSpec {
-
- fun runW(code: (widget: Widget, element: Element?) -> Unit) {
- run {
- val root = Root("test", fixed = true)
- val widget = Widget()
- widget.id = "test_id"
- root.add(widget)
- val element = document.getElementById("test_id")
- code(widget, element)
- }
- }
-
-}
-
-external fun require(name: String): dynamic
diff --git a/kvision-modules/kvision-bootstrap-spinner/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-bootstrap-spinner/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
deleted file mode 100644
index 13c8531b..00000000
--- a/kvision-modules/kvision-bootstrap-spinner/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2017-present Robert Jaros
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package test.pl.treksoft.kvision
-
-import org.w3c.dom.Element
-import pl.treksoft.jquery.jQuery
-import pl.treksoft.kvision.core.Widget
-import pl.treksoft.kvision.panel.Root
-import kotlin.browser.document
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
-
-interface TestSpec {
- fun beforeTest()
-
- fun afterTest()
-
- fun run(code: () -> Unit) {
- beforeTest()
- code()
- afterTest()
- }
-}
-
-interface SimpleSpec : TestSpec {
-
- override fun beforeTest() {
- }
-
- override fun afterTest() {
- }
-
-}
-
-interface DomSpec : TestSpec {
-
- override fun beforeTest() {
- val fixture = "<div style=\"display: none\" id=\"pretest\">" +
- "<div id=\"test\"></div></div>"
- document.body?.insertAdjacentHTML("afterbegin", fixture)
- }
-
- override fun afterTest() {
- val div = document.getElementById("pretest")
- div?.let { jQuery(it).remove() }
- jQuery(".modal-backdrop").remove()
- Root.shutdown()
- }
-
- fun assertEqualsHtml(expected: String?, actual: String?, message: String?) {
- if (expected != null && actual != null) {
- val exp = jQuery(expected)
- val act = jQuery(actual)
- val result = exp[0]?.isEqualNode(act[0])
- if (result == true) {
- assertTrue(result == true, message)
- } else {
- assertEquals(expected, actual, message)
- }
- } else {
- assertEquals(expected, actual, message)
- }
- }
-}
-
-interface WSpec : DomSpec {
-
- fun runW(code: (widget: Widget, element: Element?) -> Unit) {
- run {
- val root = Root("test", fixed = true)
- val widget = Widget()
- widget.id = "test_id"
- root.add(widget)
- val element = document.getElementById("test_id")
- code(widget, element)
- }
- }
-
-}
-
-external fun require(name: String): dynamic
diff --git a/kvision-modules/kvision-bootstrap-upload/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-bootstrap-upload/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
deleted file mode 100644
index 13c8531b..00000000
--- a/kvision-modules/kvision-bootstrap-upload/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2017-present Robert Jaros
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package test.pl.treksoft.kvision
-
-import org.w3c.dom.Element
-import pl.treksoft.jquery.jQuery
-import pl.treksoft.kvision.core.Widget
-import pl.treksoft.kvision.panel.Root
-import kotlin.browser.document
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
-
-interface TestSpec {
- fun beforeTest()
-
- fun afterTest()
-
- fun run(code: () -> Unit) {
- beforeTest()
- code()
- afterTest()
- }
-}
-
-interface SimpleSpec : TestSpec {
-
- override fun beforeTest() {
- }
-
- override fun afterTest() {
- }
-
-}
-
-interface DomSpec : TestSpec {
-
- override fun beforeTest() {
- val fixture = "<div style=\"display: none\" id=\"pretest\">" +
- "<div id=\"test\"></div></div>"
- document.body?.insertAdjacentHTML("afterbegin", fixture)
- }
-
- override fun afterTest() {
- val div = document.getElementById("pretest")
- div?.let { jQuery(it).remove() }
- jQuery(".modal-backdrop").remove()
- Root.shutdown()
- }
-
- fun assertEqualsHtml(expected: String?, actual: String?, message: String?) {
- if (expected != null && actual != null) {
- val exp = jQuery(expected)
- val act = jQuery(actual)
- val result = exp[0]?.isEqualNode(act[0])
- if (result == true) {
- assertTrue(result == true, message)
- } else {
- assertEquals(expected, actual, message)
- }
- } else {
- assertEquals(expected, actual, message)
- }
- }
-}
-
-interface WSpec : DomSpec {
-
- fun runW(code: (widget: Widget, element: Element?) -> Unit) {
- run {
- val root = Root("test", fixed = true)
- val widget = Widget()
- widget.id = "test_id"
- root.add(widget)
- val element = document.getElementById("test_id")
- code(widget, element)
- }
- }
-
-}
-
-external fun require(name: String): dynamic
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
index fc3d5242..d0b05cce 100644
--- a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
@@ -65,7 +65,7 @@ interface DomSpec : TestSpec {
val div = document.getElementById("pretest")
div?.let { jQuery(it).remove() }
jQuery(".modal-backdrop").remove()
- Root.shutdown()
+ Root.disposeAllRoots()
}
fun assertEqualsHtml(expected: String?, actual: String?, message: String?) {
diff --git a/kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
deleted file mode 100644
index 13c8531b..00000000
--- a/kvision-modules/kvision-chart/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2017-present Robert Jaros
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package test.pl.treksoft.kvision
-
-import org.w3c.dom.Element
-import pl.treksoft.jquery.jQuery
-import pl.treksoft.kvision.core.Widget
-import pl.treksoft.kvision.panel.Root
-import kotlin.browser.document
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
-
-interface TestSpec {
- fun beforeTest()
-
- fun afterTest()
-
- fun run(code: () -> Unit) {
- beforeTest()
- code()
- afterTest()
- }
-}
-
-interface SimpleSpec : TestSpec {
-
- override fun beforeTest() {
- }
-
- override fun afterTest() {
- }
-
-}
-
-interface DomSpec : TestSpec {
-
- override fun beforeTest() {
- val fixture = "<div style=\"display: none\" id=\"pretest\">" +
- "<div id=\"test\"></div></div>"
- document.body?.insertAdjacentHTML("afterbegin", fixture)
- }
-
- override fun afterTest() {
- val div = document.getElementById("pretest")
- div?.let { jQuery(it).remove() }
- jQuery(".modal-backdrop").remove()
- Root.shutdown()
- }
-
- fun assertEqualsHtml(expected: String?, actual: String?, message: String?) {
- if (expected != null && actual != null) {
- val exp = jQuery(expected)
- val act = jQuery(actual)
- val result = exp[0]?.isEqualNode(act[0])
- if (result == true) {
- assertTrue(result == true, message)
- } else {
- assertEquals(expected, actual, message)
- }
- } else {
- assertEquals(expected, actual, message)
- }
- }
-}
-
-interface WSpec : DomSpec {
-
- fun runW(code: (widget: Widget, element: Element?) -> Unit) {
- run {
- val root = Root("test", fixed = true)
- val widget = Widget()
- widget.id = "test_id"
- root.add(widget)
- val element = document.getElementById("test_id")
- code(widget, element)
- }
- }
-
-}
-
-external fun require(name: String): dynamic
diff --git a/kvision-modules/kvision-datacontainer/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-datacontainer/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
deleted file mode 100644
index 13c8531b..00000000
--- a/kvision-modules/kvision-datacontainer/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2017-present Robert Jaros
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package test.pl.treksoft.kvision
-
-import org.w3c.dom.Element
-import pl.treksoft.jquery.jQuery
-import pl.treksoft.kvision.core.Widget
-import pl.treksoft.kvision.panel.Root
-import kotlin.browser.document
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
-
-interface TestSpec {
- fun beforeTest()
-
- fun afterTest()
-
- fun run(code: () -> Unit) {
- beforeTest()
- code()
- afterTest()
- }
-}
-
-interface SimpleSpec : TestSpec {
-
- override fun beforeTest() {
- }
-
- override fun afterTest() {
- }
-
-}
-
-interface DomSpec : TestSpec {
-
- override fun beforeTest() {
- val fixture = "<div style=\"display: none\" id=\"pretest\">" +
- "<div id=\"test\"></div></div>"
- document.body?.insertAdjacentHTML("afterbegin", fixture)
- }
-
- override fun afterTest() {
- val div = document.getElementById("pretest")
- div?.let { jQuery(it).remove() }
- jQuery(".modal-backdrop").remove()
- Root.shutdown()
- }
-
- fun assertEqualsHtml(expected: String?, actual: String?, message: String?) {
- if (expected != null && actual != null) {
- val exp = jQuery(expected)
- val act = jQuery(actual)
- val result = exp[0]?.isEqualNode(act[0])
- if (result == true) {
- assertTrue(result == true, message)
- } else {
- assertEquals(expected, actual, message)
- }
- } else {
- assertEquals(expected, actual, message)
- }
- }
-}
-
-interface WSpec : DomSpec {
-
- fun runW(code: (widget: Widget, element: Element?) -> Unit) {
- run {
- val root = Root("test", fixed = true)
- val widget = Widget()
- widget.id = "test_id"
- root.add(widget)
- val element = document.getElementById("test_id")
- code(widget, element)
- }
- }
-
-}
-
-external fun require(name: String): dynamic
diff --git a/kvision-modules/kvision-redux-kotlin/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-redux-kotlin/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
deleted file mode 100644
index 13c8531b..00000000
--- a/kvision-modules/kvision-redux-kotlin/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2017-present Robert Jaros
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package test.pl.treksoft.kvision
-
-import org.w3c.dom.Element
-import pl.treksoft.jquery.jQuery
-import pl.treksoft.kvision.core.Widget
-import pl.treksoft.kvision.panel.Root
-import kotlin.browser.document
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
-
-interface TestSpec {
- fun beforeTest()
-
- fun afterTest()
-
- fun run(code: () -> Unit) {
- beforeTest()
- code()
- afterTest()
- }
-}
-
-interface SimpleSpec : TestSpec {
-
- override fun beforeTest() {
- }
-
- override fun afterTest() {
- }
-
-}
-
-interface DomSpec : TestSpec {
-
- override fun beforeTest() {
- val fixture = "<div style=\"display: none\" id=\"pretest\">" +
- "<div id=\"test\"></div></div>"
- document.body?.insertAdjacentHTML("afterbegin", fixture)
- }
-
- override fun afterTest() {
- val div = document.getElementById("pretest")
- div?.let { jQuery(it).remove() }
- jQuery(".modal-backdrop").remove()
- Root.shutdown()
- }
-
- fun assertEqualsHtml(expected: String?, actual: String?, message: String?) {
- if (expected != null && actual != null) {
- val exp = jQuery(expected)
- val act = jQuery(actual)
- val result = exp[0]?.isEqualNode(act[0])
- if (result == true) {
- assertTrue(result == true, message)
- } else {
- assertEquals(expected, actual, message)
- }
- } else {
- assertEquals(expected, actual, message)
- }
- }
-}
-
-interface WSpec : DomSpec {
-
- fun runW(code: (widget: Widget, element: Element?) -> Unit) {
- run {
- val root = Root("test", fixed = true)
- val widget = Widget()
- widget.id = "test_id"
- root.add(widget)
- val element = document.getElementById("test_id")
- code(widget, element)
- }
- }
-
-}
-
-external fun require(name: String): dynamic
diff --git a/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
deleted file mode 100644
index 13c8531b..00000000
--- a/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2017-present Robert Jaros
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package test.pl.treksoft.kvision
-
-import org.w3c.dom.Element
-import pl.treksoft.jquery.jQuery
-import pl.treksoft.kvision.core.Widget
-import pl.treksoft.kvision.panel.Root
-import kotlin.browser.document
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
-
-interface TestSpec {
- fun beforeTest()
-
- fun afterTest()
-
- fun run(code: () -> Unit) {
- beforeTest()
- code()
- afterTest()
- }
-}
-
-interface SimpleSpec : TestSpec {
-
- override fun beforeTest() {
- }
-
- override fun afterTest() {
- }
-
-}
-
-interface DomSpec : TestSpec {
-
- override fun beforeTest() {
- val fixture = "<div style=\"display: none\" id=\"pretest\">" +
- "<div id=\"test\"></div></div>"
- document.body?.insertAdjacentHTML("afterbegin", fixture)
- }
-
- override fun afterTest() {
- val div = document.getElementById("pretest")
- div?.let { jQuery(it).remove() }
- jQuery(".modal-backdrop").remove()
- Root.shutdown()
- }
-
- fun assertEqualsHtml(expected: String?, actual: String?, message: String?) {
- if (expected != null && actual != null) {
- val exp = jQuery(expected)
- val act = jQuery(actual)
- val result = exp[0]?.isEqualNode(act[0])
- if (result == true) {
- assertTrue(result == true, message)
- } else {
- assertEquals(expected, actual, message)
- }
- } else {
- assertEquals(expected, actual, message)
- }
- }
-}
-
-interface WSpec : DomSpec {
-
- fun runW(code: (widget: Widget, element: Element?) -> Unit) {
- run {
- val root = Root("test", fixed = true)
- val widget = Widget()
- widget.id = "test_id"
- root.add(widget)
- val element = document.getElementById("test_id")
- code(widget, element)
- }
- }
-
-}
-
-external fun require(name: String): dynamic
diff --git a/kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
deleted file mode 100644
index 13c8531b..00000000
--- a/kvision-modules/kvision-richtext/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2017-present Robert Jaros
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package test.pl.treksoft.kvision
-
-import org.w3c.dom.Element
-import pl.treksoft.jquery.jQuery
-import pl.treksoft.kvision.core.Widget
-import pl.treksoft.kvision.panel.Root
-import kotlin.browser.document
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
-
-interface TestSpec {
- fun beforeTest()
-
- fun afterTest()
-
- fun run(code: () -> Unit) {
- beforeTest()
- code()
- afterTest()
- }
-}
-
-interface SimpleSpec : TestSpec {
-
- override fun beforeTest() {
- }
-
- override fun afterTest() {
- }
-
-}
-
-interface DomSpec : TestSpec {
-
- override fun beforeTest() {
- val fixture = "<div style=\"display: none\" id=\"pretest\">" +
- "<div id=\"test\"></div></div>"
- document.body?.insertAdjacentHTML("afterbegin", fixture)
- }
-
- override fun afterTest() {
- val div = document.getElementById("pretest")
- div?.let { jQuery(it).remove() }
- jQuery(".modal-backdrop").remove()
- Root.shutdown()
- }
-
- fun assertEqualsHtml(expected: String?, actual: String?, message: String?) {
- if (expected != null && actual != null) {
- val exp = jQuery(expected)
- val act = jQuery(actual)
- val result = exp[0]?.isEqualNode(act[0])
- if (result == true) {
- assertTrue(result == true, message)
- } else {
- assertEquals(expected, actual, message)
- }
- } else {
- assertEquals(expected, actual, message)
- }
- }
-}
-
-interface WSpec : DomSpec {
-