diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-03-24 03:23:38 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-03-24 03:23:38 +0100 |
commit | 822ce8ad4355c3673c0c2debc3df7abb64da5386 (patch) | |
tree | 4304e15f48b4dd20652ee9b7d635370b323107dc /kvision-modules/kvision-redux/src/test | |
parent | 168c96733d8fa9ccb78f0b84376b053e8d7ee03e (diff) | |
download | kvision-822ce8ad4355c3673c0c2debc3df7abb64da5386.tar.gz kvision-822ce8ad4355c3673c0c2debc3df7abb64da5386.tar.bz2 kvision-822ce8ad4355c3673c0c2debc3df7abb64da5386.zip |
Experimental updatable redux content.
Diffstat (limited to 'kvision-modules/kvision-redux/src/test')
-rw-r--r-- | kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt b/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt index 1da16e55..0271a956 100644 --- a/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt +++ b/kvision-modules/kvision-redux/src/test/kotlin/test/pl/treksoft/kvision/redux/StateBindingSpec.kt @@ -26,6 +26,7 @@ import pl.treksoft.kvision.html.Div.Companion.div import pl.treksoft.kvision.panel.Root import pl.treksoft.kvision.panel.SimplePanel import pl.treksoft.kvision.redux.StateBinding.Companion.stateBinding +import pl.treksoft.kvision.redux.StateBinding.Companion.stateUpdate import pl.treksoft.kvision.redux.createReduxStore import redux.RAction import test.pl.treksoft.kvision.DomSpec @@ -77,4 +78,32 @@ class StateBindingSpec : DomSpec { } } -}
\ No newline at end of file + @Test + fun stateUpdate() { + run { + val root = Root("test", 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" + ) + } + } + +} |