aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-redux-kotlin/src/test
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2020-05-03 22:43:53 +0200
committerRobert Jaros <rjaros@finn.pl>2020-05-03 22:43:53 +0200
commit0b349de3cc699b54b02d7177418c8cf155afe929 (patch)
tree3b01196a3e629e1b7437f7c7e5c8eb413a4ed937 /kvision-modules/kvision-redux-kotlin/src/test
parentd502659176e11f4b1d2294e536d9e3b66b72080c (diff)
downloadkvision-0b349de3cc699b54b02d7177418c8cf155afe929.tar.gz
kvision-0b349de3cc699b54b02d7177418c8cf155afe929.tar.bz2
kvision-0b349de3cc699b54b02d7177418c8cf155afe929.zip
Simplify state binding functions. Deprecate stateBinding() in favor of bind().
Diffstat (limited to 'kvision-modules/kvision-redux-kotlin/src/test')
-rw-r--r--kvision-modules/kvision-redux-kotlin/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt37
1 files changed, 4 insertions, 33 deletions
diff --git a/kvision-modules/kvision-redux-kotlin/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt b/kvision-modules/kvision-redux-kotlin/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt
index ad90770f..cdb8821a 100644
--- a/kvision-modules/kvision-redux-kotlin/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt
+++ b/kvision-modules/kvision-redux-kotlin/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt
@@ -26,8 +26,8 @@ import pl.treksoft.kvision.panel.Root
import pl.treksoft.kvision.panel.SimplePanel
import pl.treksoft.kvision.redux.RAction
import pl.treksoft.kvision.redux.createReduxStore
+import pl.treksoft.kvision.state.bind
import pl.treksoft.kvision.state.stateBinding
-import pl.treksoft.kvision.state.stateUpdate
import test.pl.treksoft.kvision.DomSpec
import kotlin.browser.document
import kotlin.test.Test
@@ -57,51 +57,22 @@ class StateBindingSpec : DomSpec {
val store = createReduxStore(::stateReducer, State(10))
val container = SimplePanel()
- container.stateBinding(store) { state ->
+ container.bind(store) { state ->
div("${state.counter}")
}
root.add(container)
val element = document.getElementById("test")
assertEqualsHtml(
- "<div><div></div><div>10</div></div>",
+ "<div><div>10</div></div>",
element?.innerHTML,
"Should render initial state of the container"
)
store.dispatch(StateAction.Inc)
assertEqualsHtml(
- "<div><div></div><div>11</div></div>",
+ "<div><div>11</div></div>",
element?.innerHTML,
"Should render changed state of the container"
)
}
}
-
- @Test
- fun stateUpdate() {
- run {
- val root = Root("test", fixed = true)
- val store = createReduxStore(::stateReducer, State(10))
-
- val container = SimplePanel()
- container.stateUpdate(store) { state ->
- div("${state.counter}")
- } updateWith { state, d ->
- d.content = "${state.counter}"
- }
- root.add(container)
- val element = document.getElementById("test")
- assertEqualsHtml(
- "<div><div></div><div>10</div></div>",
- element?.innerHTML,
- "Should render initial state of the container"
- )
- store.dispatch(StateAction.Inc)
- assertEqualsHtml(
- "<div><div></div><div>11</div></div>",
- element?.innerHTML,
- "Should render changed state of the container"
- )
- }
- }
-
}